Skip to content Skip to sidebar Skip to footer

Include Unexpected. Element Has To Be Either A Model, An Association Or An Object

I have a problem trying to configure postrgres with nodeJs, i followed this tutorial and i get a error that doesn't specify anything about what is wrong: here is the stacktrace Unh

Solution 1:

Is posible that you have a problem with the depth of your model path, check first if that is the correct path. Alternatively, you can manage your require imports as suggested here, it will result really handy and useful.

Solution 2:

models exports a function with the parameters (sequelize, DataTypes), yet it is invoked without bring provided parameters. You first need to invoke your models function with the right parameters, and then assign the returned models to variables. Ugliest case, you could write:

var User = models(sequelize, DataTypes).User;

...after having initialized sequelize and DataTypes in your router. But you should probably do that in the models file and restructure that file to have an initializer.

Post a Comment for "Include Unexpected. Element Has To Be Either A Model, An Association Or An Object"