Skip to content

Instantly share code, notes, and snippets.

@Jigarsolanki
Created December 9, 2012 06:53
Show Gist options
  • Save Jigarsolanki/4243637 to your computer and use it in GitHub Desktop.
Save Jigarsolanki/4243637 to your computer and use it in GitHub Desktop.
sync in async way
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