Javascript node.js ORM that follows data

I've been working with active record and data mapper implementations of ORM enough to know the problems with using active record implemented ORM in my large projects. Right now I'm thinking to migrate one of my projects to node.js and trying to find the similar tools Im using right now. After research I didn't found any node.js ORM that follows data mapper pattern. They all are active record. Maybe I missing something, and you can tell me is there is a good popular ORM for node.js that doesn't follow active record pattern?

The libraries Ive looked on:

  • http://docs.sequelizejs.com/
  • https://github.com/dresende/node-orm2
  • http://bookshelfjs.org/
  • some others

  • 在经历了很多关于JavaScript的ORM之后,我写了自己的支持TypeScript / ES6 / ES5的ORM,并遵循数据映射器模式和所有其他最佳实践 - TypeORM


    I wrote an ORM for Node.js called node-data-mapper; it's available here: https://www.npmjs.com/package/node-data-mapper. It's an ORM for Node.js that uses the data-mapper pattern. The developer uses plain old JavaScript objects when reading from and writing to the database. Relationships between tables are not rigidly defined, which makes joining very flexible--in my opinion, anyway--albeit somewhat verbose. The actual data mapping algorithm is fast and short, and the complexity is linear (the transformation from tabular DB data to a normalized JavaScript object is done in one loop).

    I also did my best to make it fairly fault tolerant. There's 100% code coverage and, while I know that doesn't prove the absence of defects, I did try to test as thoroughly as possible.

    I modeled the interface very loosely after Doctrine 1. (I've used LINQ, Doctrine 1 and 2, and Hibernate fairly extensively, and of those ORMs I like the interface for Doctrine 1 the best. node-data-mapper is not a JavaScript port of Doctrine by any means, though, and the interface is significantly different.) The query interface returns promises using the deferred module.

    I modeled the conditions (eg WHERE and ON clauses) after MongoDB's conditions. Hopefully that makes the conditions somewhat intuitive while providing a way for making reusable queries (specifically, complex SELECT queries that can be filtered securely in many different ways). The conditions are treated as a domain-specific language, and are lexed, parsed, and compiled.

    Anyway, the module is something that I use in my personal projects, but I'd love to get some feedback from other developers in the community! I tried to provide plenty of examples to get people up and running quickly. Currently the module supports MySQL only, but I'm working on adding support for MSSQL.


    The distinction between data-mapper pattern and active record doesn't really make sense in the dynamic language such as JavaScript. Typically data mapper is more lightweight in typed language, but in JS it does not really make a difference. From the top of my head, I can mention two very popular projects which you probably don't know:

    Waterline.js is a Sails abstraction, which works quite well on top of many database systems.

    If you would consider MongoDB for your DB - Mongoose.js.

    链接地址: http://www.djcxy.com/p/17206.html

    上一篇: 使用文件输入运行Java程序

    下一篇: Javascript node.js ORM跟随数据