Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. users = sequelize.define('users', {
  2. id: {
  3. type: Sequelize.INTEGER,
  4. primaryKey: true,
  5. autoIncrement: true
  6. },
  7. name: Sequelize.TEXT,
  8. type: Sequelize.INTEGER
  9.  
  10. profiles = sequelize.define('profiles', {
  11. id: {
  12. type: Sequelize.INTEGER,
  13. primaryKey: true,
  14. autoIncrement: true
  15. },
  16. place: Sequelize.TEXT,
  17. phone: Sequelize.INTEGER
  18.  
  19. profiles.belongsTo(users, {foreignKey: 'id'});
  20.  
  21. users.findOne({
  22. where: {name: 'John'},
  23. include: [{model: db.tables.profiles}]
  24. }).then(function(user_data) {
  25. console.log(user_data);
  26. })
  27.  
  28. users.hasMany(profiles, {
  29. foreignKey: 'id'
  30. });
  31.  
  32. profiles.belongsTo(users, {
  33. foreignKey: 'user_id'
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement