Created
December 9, 2012 06:53
-
-
Save Jigarsolanki/4243637 to your computer and use it in GitHub Desktop.
sync in async way
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 Sequelize = require('sequelize'); | |
var sequelize = new Sequelize('userpets', 'dbuser', 'dbpassword', { | |
host: 'localhost', //mysql host name | |
port: 3306 //default mysql port | |
}); | |
var User = sequelize.define( | |
'User', | |
{ | |
firstName: { type: Sequelize.STRING }, | |
lastName: { type: Sequelize.STRING }, | |
password: { type: Sequelize.STRING }, | |
numberOfPets: { type: Sequelize.INTEGER } | |
} | |
); | |
User | |
.sync() | |
.on('success', function () { | |
User.create({ | |
firstName: 'foo', | |
lastName: 'bar', | |
password: 'asdfasdf', | |
numberOfPets: 0 | |
}); | |
}) | |
.on('error', function (e) { | |
console.log('Something went wrong!', e) | |
}); | |
exports.User = User; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment