任何适用于 Node.js 的 Postgres 兼容 ORM?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8041846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Any Postgres compatible ORM for Node.js?
提问by arnaud briche
I'm seeking for a good ORM for postgres under Node.js, one that supports declaration of relationships beetween models, and fields validation. I've searched during a long time and cannot get any satisfying results. Maybe someone can point me to a project I missed during my researches. Thx.
我正在为 Node.js 下的 postgres 寻找一个好的 ORM,一个支持模型之间关系声明和字段验证的 ORM。我已经搜索了很长时间,没有得到任何令人满意的结果。也许有人可以指出我在研究过程中错过的一个项目。谢谢。
采纳答案by RyanWilcox
回答by vladexologija
SequelizeJS- models, validation and migrations
SequelizeJS- 模型、验证和迁移
BookshelfJS- a promise based ORM looks quite promising
BookshelfJS- 基于承诺的 ORM 看起来很有前途
回答by Anatoliy
JugglingDB- multidatabase ORM inspired by activerecord and datamapper. Supports validations, hooks, relations. Works with: mysql, postgres, sqlite, memory, redis, mongodb, neo4j.
JugglingDB- 受 activerecord 和 datamapper 启发的多数据库 ORM。支持验证、挂钩、关系。适用于:mysql、postgres、sqlite、内存、redis、mongodb、neo4j。
Not production ready now (march 2012), but growing fast. I plan stable release soon.
现在还没有准备好生产(2012 年 3 月),但增长很快。我计划很快发布稳定版。
回答by dmp
Would recommend trying Knexfor the database and Bookshelfas an ORM on top of it (developed by same person). I'm using it with postgres, but supports SQLite, MySQL/MariaDB and Oracle (in alpha) too.
建议将Knex用于数据库和Bookshelf作为其上的 ORM(由同一人开发)。我将它与 postgres 一起使用,但也支持 SQLite、MySQL/MariaDB 和 Oracle(在 alpha 中)。
Very expressive promise-based API with bluebirdbehind it, knex has a well documented and great command line tool for making migrations, seed files etc. Bookshelf uses backbone models and collections as an inspiration, including the .extend(..)paradigm for inheritance, so picking it up is a breeze if you come from that world. So far, so good.
非常有表现力的基于承诺的 APIbluebird背后,knex 有一个记录良好且很棒的命令行工具,用于进行迁移、种子文件等。 Bookshelf 使用主干模型和集合作为灵感,包括.extend(..)继承范式,所以拿起它是一个如果你来自那个世界,那就是微风。到现在为止还挺好。
回答by kolypto
回答by Oleksandr Knyga
I suggest you use this pair: pg(like a driver) and light-orm(like orm wrapper).
我建议你使用这对:pg(像驱动程序)和light-orm(像 orm 包装器)。
回答by Lars-Erik Roald
https://www.npmjs.org/package/rdb
Simple, flexible mapper.
Transaction with commit and rollback.
Persistence ignorance - no need for explicit saving, everything is handled by transaction.
Eager or lazy loading.
Based on promises.
Well documented by (running) examples.
https://www.npmjs.org/package/rdb
简单、灵活的映射器。
带有提交和回滚的事务。
持久性无知 - 无需显式保存,一切都由事务处理。
急切或延迟加载。
基于承诺。
(运行)示例有很好的记录。
回答by sergeych
ORM's are a little too slow for fast nature of node.js; plain database driver is fine, but a little tiring. That's for I do write something just between: prego. It provides automatic statement preparation, migrations, simple models with associations, transactions and few utilities, all callback style and fast. Ideas/issues are welcome.
ORM 对于 node.js 的快速特性来说有点太慢了;普通的数据库驱动程序很好,但有点累。那是因为我确实在两者之间写了一些东西:prego。它提供自动语句准备、迁移、带有关联、事务和少量实用程序的简单模型,所有回调样式和快速。欢迎提出想法/问题。

