Skip to content

Instantly share code, notes, and snippets.

@banyudu
Last active June 21, 2017 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banyudu/8c28b8a6b3e0eda3108733854b13a0d5 to your computer and use it in GitHub Desktop.
Save banyudu/8c28b8a6b3e0eda3108733854b13a0d5 to your computer and use it in GitHub Desktop.
const sequelize = require('sequelize')
const db = new sequelize('test', 'test', '', {
dialect: 'postgres',
host: '127.0.0.1',
port: 5432,
})
const Foo = db.define('foo')
const Bar = db.define('bar')
Foo.belongsTo(Bar, {as: 'foo'})
// as 'foo' multi times will throw exception in sequelize@4
// You have used the alias foo in two separate associations. Aliased associations must have unique aliases.
// sequelize@3 will work as normal
Foo.belongsTo(Bar, {as: 'foo'})
// use a new alias name will fix this issue
Foo.belongsTo(Bar, {as: 'another'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment