Tags
nodejsdatabase
Created
Feb 17, 2017 8:49 AM
其他 ORM:
https://github.com/sequelize/sequelize
查询:http://docs.sequelizejs.com/manual/tutorial/querying.html
更新表:https://stackoverflow.com/questions/46357533/how-to-add-delete-new-columns-in-sequelize-cli
ORM 一般使用教程:http://www.ruanyifeng.com/blog/2019/02/orm-tutorial.html
Sequelize is a promise-based ORM for Node.js and io.js. It supports the dialects PostgreSQL, MySQL,MariaDB, SQLite and MSSQL and features solid transaction support, relations, read replication and more.
Sequelize supports adding indexes to the model definition which will be created during Model.sync() or sequelize.sync.
查询:https://itbilu.com/nodejs/npm/VJIR1CjMb.html
操作符:http://docs.sequelizejs.com/variable/index.html#static-variable-Op
// 事物
sequelize.transaction().then(transaction => {
return User.find(..., {transaction})
.then(user => user.updateAttributes(..., {transaction}))
.then(() => transaction.commit())
.catch(() => transaction.rollback());
})