MCPcopy Create free account
hub / github.com/sequelize/sequelize / toDefaultValue

Function toDefaultValue

src/utils.js:269–293  ·  view source on GitHub ↗
(value, dialect)

Source from the content-addressed store, hash-verified

267exports.combineTableNames = combineTableNames;
268
269function toDefaultValue(value, dialect) {
270 if (typeof value === 'function') {
271 const tmp = value();
272 if (tmp instanceof DataTypes.ABSTRACT) {
273 return tmp.toSql();
274 }
275 return tmp;
276 }
277 if (value instanceof DataTypes.UUIDV1) {
278 return uuidv1();
279 }
280 if (value instanceof DataTypes.UUIDV4) {
281 return uuidv4();
282 }
283 if (value instanceof DataTypes.NOW) {
284 return now(dialect);
285 }
286 if (Array.isArray(value)) {
287 return value.slice();
288 }
289 if (_.isPlainObject(value)) {
290 return { ...value };
291 }
292 return value;
293}
294exports.toDefaultValue = toDefaultValue;
295
296/**

Callers

nothing calls this directly

Calls 2

nowFunction · 0.85
toSqlMethod · 0.65

Tested by

no test coverage detected