Skip to content

Instantly share code, notes, and snippets.

@nehalist
Created August 7, 2016 14:03
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 nehalist/4ae5761dd8d2d37a53dd3ec8e754272f to your computer and use it in GitHub Desktop.
Save nehalist/4ae5761dd8d2d37a53dd3ec8e754272f to your computer and use it in GitHub Desktop.
// models/Project.js
module.exports = {
attributes: {
title: {
type: Sequelize.STRING
}
},
associations: function() {
Project.belongsTo(Customer);
Project.hasMany(Contributor);
}
};
// models/Contributor.js
module.exports = {
attributes: {
note: {
type: Sequelize.STRING
},
},
associations: function() {
Contributor.belongsTo(Project);
Contributor.belongsTo(User);
}
};
// models/Customer.js
module.exports = {
attributes: {
name: {
type: Sequelize.STRING
}
},
associations: function() {
Customer.hasMany(Project);
}
};
// models/User.js
module.exports = {
attributes: {
username: {
type: Sequelize.STRING
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment