rdb Node.js 的 ORM 框架开源项目

我要开发同款
匿名用户2015年02月21日
85阅读

技术信息

开源地址
https://gitee.com/mirrors/rdb
授权协议
MIT

作品详情

rdb是Node.js的一个ORM框架,支持Postgres和MySQL数据库。

特点:

简单灵活的映射器

支持事务处理

可定制的持久化策略

支持延迟加载

基于promises.

示例代码:

var rdb = require('rdb');var Customer = rdb.table('_customer');Customer.primaryColum('cId').guid().as('id');Customer.colum('cName').strig().as('ame');Customer.colum('cBalace').umeric().as('balace');Customer.colum('cRegdate').date().as('registeredDate');Customer.colum('cIsActive').boolea().as('isActive');Customer.colum('cPicture').biary().as('picture');var db = rdb('postgres://postgres:postgres@localhost/test');db.trasactio()    .the(getById)    .the(pritCustomer)    .the(rdb.commit)    .the(ull, rdb.rollback)    .the(oOk, oFailed);fuctio getById() {    retur Customer.getById('a0000000-0000-0000-0000-000000000000');}fuctio pritCustomer(customer) {    var format = 'Customer Id: %s, ame: %s, Balace: %s, Registered Date: %s, Is Active: %s, Picture: %s';     var args = [format, customer.id, customer.ame, customer.balace, customer.registeredDate, customer.isActive, customer.picture];    cosole.log.apply(ull,args);}fuctio oOk() {    cosole.log('Success');    cosole.log('Waitig for coectio pool to teardow....');}fuctio oFailed(err) {    cosole.log('Rollback');    cosole.log(err);}

功能介绍

rdb 是 Node.js 的一个 ORM 框架,支持 Postgres 和 MySQL 数据库。 特点: 简单灵活的映射器 支持事务处理 可定制的持久化策略 支持延迟加载 基于 promise...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论