MCPcopy
hub / github.com/sequelize/sequelize / toDefaultValue

Function toDefaultValue

lib/utils.js:256–280  ·  view source on GitHub ↗
(value, dialect)

Source from the content-addressed store, hash-verified

254exports.combineTableNames = combineTableNames;
255
256function toDefaultValue(value, dialect) {
257 if (typeof value === 'function') {
258 const tmp = value();
259 if (tmp instanceof DataTypes.ABSTRACT) {
260 return tmp.toSql();
261 }
262 return tmp;
263 }
264 if (value instanceof DataTypes.UUIDV1) {
265 return uuidv1();
266 }
267 if (value instanceof DataTypes.UUIDV4) {
268 return uuidv4();
269 }
270 if (value instanceof DataTypes.NOW) {
271 return now(dialect);
272 }
273 if (Array.isArray(value)) {
274 return value.slice();
275 }
276 if (_.isPlainObject(value)) {
277 return { ...value };
278 }
279 return value;
280}
281exports.toDefaultValue = toDefaultValue;
282
283/**

Callers

nothing calls this directly

Calls 2

nowFunction · 0.85
toSqlMethod · 0.65

Tested by

no test coverage detected