一个新的Node.js数据库ORM:Moron.js
cp6p
10年前
Moron.js是一个新的 Node.js 数据库 ORM,它基于 SQL Builder Knex.js,因此完全支持 SQLite、PostgreSQL、MySQL。Moron.js 给基础的 CRUD 提供了一个非常语义化的 Query 方法,完全基于 Promise,还可以存储一个 document到一个 row。
Person .query() .insert({firstName: 'Jennifer', lastName: 'Lawrence'}) .then(function (jennifer) { console.log(jennifer instanceof Person); // --> true console.log(jennifer.firstName); // --> 'Jennifer' console.log(jennifer.fullName()); // --> 'Jennifer Lawrence' }) .catch(function (err) { console.log('oh noes'); });
What moron.js gives you:
- An easy declarative way of defining models and relations between them
- Simple and fun way to fetch, insert, update and delete models using the full power of SQL
- A way to store complex documents as single rows
- Powerful mechanism for loading arbitrarily large trees of relations
- Completely Promise based API
- Simple transactions
- JSON schema validation