Sequelize.js提供对MySQL,MariaDB,SQLite和PostgreSQL数据库的简单访问,通过映射数据库条目到对象,或者对象到数据库条目。简而言之,就是ORM(Object-Relational-Mapper)。Sequelize.js完全是使用JavaScript编写,适用于Node.js的环境。
简单使用创建Sequelize实例:
var sequelize = new Sequelize('database', 'username'[, 'password'])指定host/port:
var sequelize = new Sequelize('database', 'username', 'password', { host: "my.server.tld", port: 12345})没有密码的情况:
var sequelize = new Sequelize('database', 'username')// orvar sequelize = new Sequelize('database', 'username', null)使用连接字符串:
var sequelize = new Sequelize('mysql://user:pass@example.com:9821/dbname', { // Look to the next section for possible options})
评论