Created
August 13, 2012 08:34
-
-
Save asinbow/3338259 to your computer and use it in GitHub Desktop.
Sequelize ORM operations
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('db', 'user', 'pass', { | |
dialect: 'mysql', | |
pool: { | |
maxConnections: 5, | |
maxIdleTime: 30 | |
} | |
}); | |
var User = sequelize.define("User", { | |
chinese_name: Sequelize.STRING, | |
english_name: Sequelize.STRING, | |
login_ip: Sequelize.STRING, | |
}, { | |
timestamp: true, | |
underscored: true, | |
freezeTableName: true | |
}); | |
User.findAll({where: {passport_id: "83651326"}}).success(function(users){ | |
console.log(users[0].values); | |
}); | |
User.findAll({where: {unknown_column: 0}}).success(function(users){ | |
console.log(users[0].values); | |
}).error(function(error){ | |
console.log(error); | |
}); | |
exports.User = User; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment