Guest User

Untitled

a guest
Jan 21st, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. const { DataTypes } = require('sequelize');
  2. const ApplicationRecord = require('./application-record');
  3.  
  4. const Foo = require('./foo');
  5.  
  6. const Boo = ApplicationRecord.define('Boo', {
  7. fooId: DataTypes.INTEGER,
  8. booName: DataTypes.STRING
  9. }, {});
  10.  
  11.  
  12. // Boo.belongsTo(Foo); <= 這樣會噴掉, 因為跟 Foo 有循環引用, boo 就變成 defefined
  13. Boo.belongsTo(ApplicationRecord.define('foo'), { as: 'foo' });
  14.  
  15. module.exports = Boo;
Add Comment
Please, Sign In to add comment