我应该为 Node.js 和 MySQL 使用哪个 ORM?

2022-01-01 00:00:00 node.js orm mysql

我正在重写一个项目以使用 Node.js.我想继续使用 MySQL 作为数据库(即使我不介意重写架构).我正在寻找一种易于使用、性能合理的 ORM,它支持缓存、多对一和多对多关系.从我能找到的 MySQL ORM 中,persistencejs 和 sequelize 看起来最成熟.你有这方面的经验吗?在我的决定中,我应该注意哪些相关的利弊?

I'm rewriting a project to use Node.js. I'd like to keep using MySQL as the DB (even though I don't mind rewriting the schema). I'm looking for a simple-to-use, reasonable-performance ORM, which supports caching, many-to-one and many-to-many relations. From the MySQL ORMs I could find, persistencejs and sequelize seem the most mature. Do you have experience with either? What are the relevant pros and cons I should be aware of in my decision?

推荐答案

我可以推荐 Node ORM 吗?

May I suggest Node ORM?

https://github.com/dresende/node-orm2

Readme 中有文档,支持 MySQL、PostgreSQL 和 SQLite.

There's documentation on the Readme, supports MySQL, PostgreSQL and SQLite.

MongoDB 自 2.1.x 版本(2013 年 7 月发布)起可用

MongoDB is available since version 2.1.x (released in July 2013)

更新:根据项目的自述文件,此包不再维护.相反,它推荐 bookshelf 和 续集

UPDATE: This package is no longer maintained, per the project's README. It instead recommends bookshelf and sequelize

相关文章