sequelize: 3.5.1
I'm trying to create a very basic model for testing purposes. Here is the code:
'use strict';
var Constants = require('../../utils/constants');
var Sequelize = require('sequelize');
var sequelize = new Sequelize(process.env.DATABASE_URL, { dialect: 'postgres' });
var Users = sequelize.define('user', {
username: {
type: sequelize.STRING,
unique: true
},
email: {
type: sequelize.STRING,
unique: true
}
});
Users.schema(Constants.API_VERSION);
process.env.NODE_ENV === 'development' && Users.sync();
module.exports = Users;
However, I'm getting the following error:
Error: Unrecognized data type for field username
What am I missing? Thanks!
Looks correct to me - has this started appearing on 3.5.1, or do you also experience it on older versions? Can you try console.logging sequelize.STRING
- and if that is undefined then sequelize
This is the first I'm using sequelize, so I'm not sure if the issue is new to 3.5.1.
sequelize.STRING === undefined
sequelize = {
options: {
dialect: 'postgres'
...
},
config: {
...
}
}
Ah, sorry I didn't notice earlier - the datatypes are on the sequelize constructor Sequelize
, not the instance
Most helpful comment
Ah, sorry I didn't notice earlier - the datatypes are on the sequelize constructor
Sequelize
, not the instance