MCPcopy
hub / github.com/sequelize/sequelize / toInstanceArray

Method toInstanceArray

lib/associations/base.js:121–134  ·  view source on GitHub ↗

* Normalize input * * @param {Array|string} input it may be array or single obj, instance or primary key * * @private * @returns {Array} built objects

(input)

Source from the content-addressed store, hash-verified

119 * @returns {Array} built objects
120 */
121 toInstanceArray(input) {
122 if (!Array.isArray(input)) {
123 input = [input];
124 }
125
126 return input.map(element => {
127 if (element instanceof this.target) return element;
128
129 const tmpInstance = {};
130 tmpInstance[this.target.primaryKeyAttribute] = element;
131
132 return this.target.build(tmpInstance, { isNewRecord: false });
133 });
134 }
135
136 [Symbol.for('nodejs.util.inspect.custom')]() {
137 return this.as;

Callers 6

setMethod · 0.80
addMethod · 0.80
removeMethod · 0.80
setMethod · 0.80
addMethod · 0.80
removeMethod · 0.80

Calls 1

buildMethod · 0.80

Tested by

no test coverage detected