Created
February 1, 2013 14:25
-
-
Save mlaccetti/4691593 to your computer and use it in GitHub Desktop.
associations in sequelize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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