github http://github.com/sdepold/sequelize
可以定義結構,同步資料庫,新增修改刪除,join資料表。
是目前我看過 nodejs orm 模組裡面最完整且介面設計蠻容易的。
且 github 上此類型較多人追蹤的專案。
//database connection
var sequelize = new Sequelize('database', 'username', 'password', {
host: "my.server.tld",
port: 12345
})
//define struct
var Project = sequelize.define('Project', {
title: Sequelize.STRING,
description: Sequelize.TEXT
})
//insert
var project = new Project({
title: 'my awesome project',
description: 'woot woot. this will make me a rich man'
});
project.save();
//where
Project.find({ title: 'aProject' }, function(project) {
// project will be the first entry of the Projects table
//with the title 'aProject' || null
})
//join
Project.hasMany('member')