mvom
Version:
Multivalue Object Mapper
36 lines (29 loc) • 874 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
class StringDataTransformer {
/** Array of allowed enumerations */
constructor(enumList) {
this.enum = enumList ?? null;
}
/** Transform mv string to js string */
transformFromDb(value) {
if (value == null) {
// if this property has an enumeration constraint and one of those constraints is empty string then return empty string;
// otherwise return null
return this.enum?.includes('') ? '' : null;
}
return String(value);
}
/** Transform js string to mv string */
transformToDb(value) {
return value == null ? null : String(value);
}
/** Transform query constants to the format schema */
transformToQuery(value) {
return String(value);
}
}
var _default = exports.default = StringDataTransformer;