You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sequelize findOrCreate function looks for one element and if it is found, returns an Array that contains [elementFound, created].
Where elementFound is an Instance and created is a boolean. If the conditions of the query match more than one element, it just returns the first one (array index 0), like noted in the comment:
In the example above, the array spread on line 3 divides the array into its 2 parts and passes them
as arguments to the callback function defined beginning at line 39, which treats them as "user" and
"created" in this case. (So "user" will be the object from index 0 of the returned array and
"created" will equal "true".)
In Sequelize-mock docs the findOrCreate reflects that it returns Promise.<Array.<Instance, Boolean>> but it actually returns Promise.<Array.<Array<Instance>, Boolean>>.
That second Array is not supposed to be there. Must return the 0 index of that array.
The text was updated successfully, but these errors were encountered:
Sequelize findOrCreate function looks for one element and if it is found, returns an Array that contains
[elementFound, created]
.Where elementFound is an Instance and created is a boolean. If the conditions of the query match more than one element, it just returns the first one (array index 0), like noted in the comment:
http://docs.sequelizejs.com/manual/models-usage.html
In Sequelize-mock docs the findOrCreate reflects that it returns
Promise.<Array.<Instance, Boolean>>
but it actually returnsPromise.<Array.<Array<Instance>, Boolean>>
.That second Array is not supposed to be there. Must return the 0 index of that array.
The text was updated successfully, but these errors were encountered: