Skip to content

Instantly share code, notes, and snippets.

@mlaccetti
Created February 1, 2013 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mlaccetti/4691593 to your computer and use it in GitHub Desktop.
Save mlaccetti/4691593 to your computer and use it in GitHub Desktop.
associations in sequelize
var Manufacturer = sequelize.define('manufacturer', {
name:DataTypes.STRING
});
var GraphicsCard = sequelize.define("graphics_card", {
model:DataTypes.STRING,
RAM:DataTypes.INTEGER
});
GraphicsCard.belongsTo(Manufacturer);
Manufacturer.hasMany(GraphicsCard);
var amd = Manufacturer.create({name:'AMD'});
var gc650m = GraphicsCard.create({model:'650m', RAM:2});
gc650.setManufacturer(amd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment