MCPcopy
hub / github.com/sequelize/sequelize / constructor

Method constructor

lib/model.js:85–120  ·  view source on GitHub ↗

* Builds a new model instance. * * @param {object} [values={}] an object of key value pairs * @param {object} [options] instance construction options * @param {boolean} [options.raw=false] If set to true, values will ignore field and virtual setters. * @param {boolean} [options.isNe

(values = {}, options = {})

Source from the content-addressed store, hash-verified

83 * @param {Array} [options.include] an array of include options - Used to build prefetched/included model instances. See `set`
84 */
85 constructor(values = {}, options = {}) {
86 options = {
87 isNewRecord: true,
88 _schema: this.constructor._schema,
89 _schemaDelimiter: this.constructor._schemaDelimiter,
90 ...options
91 };
92
93 if (options.attributes) {
94 options.attributes = options.attributes.map(attribute => Array.isArray(attribute) ? attribute[1] : attribute);
95 }
96
97 if (!options.includeValidated) {
98 this.constructor._conformIncludes(options, this.constructor);
99 if (options.include) {
100 this.constructor._expandIncludeAll(options);
101 this.constructor._validateIncludedElements(options);
102 }
103 }
104
105 this.dataValues = {};
106 this._previousDataValues = {};
107 this.uniqno = 1;
108 this._changed = new Set();
109 this._options = options;
110
111 /**
112 * Returns true if this instance has not yet been persisted to the database
113 *
114 * @property isNewRecord
115 * @returns {boolean}
116 */
117 this.isNewRecord = options.isNewRecord;
118
119 this._initValues(values, options);
120 }
121
122 _initValues(values, options) {
123 let defaults;

Callers

nothing calls this directly

Calls 4

_initValuesMethod · 0.95
_conformIncludesMethod · 0.80
_expandIncludeAllMethod · 0.80

Tested by

no test coverage detected