<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          rdbNode.js 的 ORM 框架

          聯(lián)合創(chuàng)作 · 2023-09-23 16:58

          rdb 是 Node.js 的一個(gè) ORM 框架,支持 Postgres 和 MySQL 數(shù)據(jù)庫。

          特點(diǎn):

          • 簡(jiǎn)單靈活的映射器

          • 支持事務(wù)處理

          • 可定制的持久化策略

          • 支持延遲加載

          • 基于 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);
          }
          瀏覽 6
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  性三级视频 | 亚洲欧洲欧美日韩中文字幕 | 亚洲视频网站在线 | 经典无码一区二区三区 | 一级A毛片视频破 |