Sequelize: 3.5.1: Unrecognized data type for field

Created on 17 Aug 2015  路  3Comments  路  Source: sequelize/sequelize

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!

Most helpful comment

Ah, sorry I didn't notice earlier - the datatypes are on the sequelize constructor Sequelize, not the instance

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wibud picture wibud  路  3Comments

haikyuu picture haikyuu  路  3Comments

lfcgomes picture lfcgomes  路  3Comments

davidleureka picture davidleureka  路  3Comments

hendrul picture hendrul  路  3Comments