Node.js 的 ORM 框架 rdb
- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://www.npmjs.com/package/rdb
- 软件文档: https://github.com/alfateam/rdb/blob/master/docs/docs.md
软件介绍
rdb 是 Node.js 的一个 ORM 框架,支持 Postgres 和 MySQL 数据库。
特点:
简单灵活的映射器
支持事务处理
可定制的持久化策略
支持延迟加载
基于 promises.
示例代码:
var rdb = require('rdb');
var Customer = rdb.table('_customer');
Customer.primaryColumn('cId').guid().as('id');
Customer.column('cName').string().as('name');
Customer.column('cBalance').numeric().as('balance');
Customer.column('cRegdate').date().as('registeredDate');
Customer.column('cIsActive').boolean().as('isActive');
Customer.column('cPicture').binary().as('picture');
var db = rdb('postgres://postgres:postgres@localhost/test');
db.transaction()
.then(getById)
.then(printCustomer)
.then(rdb.commit)
.then(null, rdb.rollback)
.then(onOk, onFailed);
function getById() {
return Customer.getById('a0000000-0000-0000-0000-000000000000');
}
function printCustomer(customer) {
var format = 'Customer Id: %s, name: %s, Balance: %s, Registered Date: %s, Is Active: %s, Picture: %s';
var args = [format, customer.id, customer.name, customer.balance, customer.registeredDate, customer.isActive, customer.picture];
console.log.apply(null,args);
}
function onOk() {
console.log('Success');
console.log('Waiting for connection pool to teardown....');
}
function onFailed(err) {
console.log('Rollback');
console.log(err);
}
零基础学Minecraft编程
Martin O''Hanlon、David Whale / 中文Minecraft Wiki翻译团队 / 人民邮电出版社 / 2015-9-7 / 79
在你体验Minecraft冒险的同时,学习宝贵的编程技能! 如果你很喜欢玩Minecraft,却被游戏中的建造耗费大量时间而困扰,并且你想要对游戏添加一些改动,那么本书就是为你而设计的。在游戏中,你可以学习许多Python编程技能,在PC、Mac或树莓派上与游戏进行互动。这些冒险不仅局限在虚拟世界——你也将会学习如何将Minecraft与电子元件连接起来,这样你的Minecraft世界就能够......一起来看看 《零基础学Minecraft编程》 这本书的介绍吧!
