typecql
Version:
ORM for CQL databases.
29 lines • 948 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = mergeDefaultValueByKey;
const EntitiesData_1 = require("./utils/EntitiesData");
function mergeDefaultValueByKey(key, value, tableName) {
const schema = EntitiesData_1.default.entitiesShemes[tableName];
if (typeof value == 'function') {
value = value();
}
if (!schema)
return null;
let defaultValue = null;
const type = schema[key];
if (type?.startsWith('map') || type?.startsWith('frozen<map')) {
defaultValue = {};
}
if (type?.startsWith('set') ||
type?.startsWith('frozen<set') ||
type?.startsWith('list') ||
type?.startsWith('frozen<list')) {
defaultValue = [];
}
if (value === null)
return defaultValue;
if (typeof value === 'undefined')
return defaultValue;
return value;
}
//# sourceMappingURL=mergeDefaultValueByKey.js.map