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
I'm trying to use sequelize-mock as a drop-in replacement of regular sequelize. Following snippet is from models/index.js that is using either sequelize-mock or sequelize based on environment
All works great except that Sequelize.define from sequelize-mock behaves different. It using its second argument as columns default values, while the one from sequelize using second argument as columns configuration. So given model's code is
then sequelize-mock will be using { type: Sequelize.STRING, field: 'class_name' } as a default value for name column.
Question: Is it something that never supposed to work this way or am I missing something?
P.S. Since apart from that it works for me I've overridden define method to reset _defaults field that there're no default values for columns:
const{ define }=SequelizeMock.prototype;SequelizeMock.prototype.define=(...args)=>{constmodel=define(...args);model._defaults={};// or going through model attributes and using `defaultValue` if it existsreturnmodel;};
The text was updated successfully, but these errors were encountered:
I'm trying to use
sequelize-mock
as a drop-in replacement of regularsequelize
. Following snippet is frommodels/index.js
that is using either sequelize-mock or sequelize based on environmentAll works great except that
Sequelize.define
fromsequelize-mock
behaves different. It using its second argument as columns default values, while the one fromsequelize
using second argument as columns configuration. So given model's code isthen
sequelize-mock
will be using{ type: Sequelize.STRING, field: 'class_name' }
as a default value forname
column.Question: Is it something that never supposed to work this way or am I missing something?
P.S. Since apart from that it works for me I've overridden
define
method to reset_defaults
field that there're no default values for columns:The text was updated successfully, but these errors were encountered: