Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- users = sequelize.define('users', {
- id: {
- type: Sequelize.INTEGER,
- primaryKey: true,
- autoIncrement: true
- },
- name: Sequelize.TEXT,
- type: Sequelize.INTEGER
- profiles = sequelize.define('profiles', {
- id: {
- type: Sequelize.INTEGER,
- primaryKey: true,
- autoIncrement: true
- },
- place: Sequelize.TEXT,
- phone: Sequelize.INTEGER
- profiles.belongsTo(users, {foreignKey: 'id'});
- users.findOne({
- where: {name: 'John'},
- include: [{model: db.tables.profiles}]
- }).then(function(user_data) {
- console.log(user_data);
- })
- users.hasMany(profiles, {
- foreignKey: 'id'
- });
- profiles.belongsTo(users, {
- foreignKey: 'user_id'
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement