简体   繁体   English

使用NodeJ和MongoDB存储事件的最佳实践是什么

[英]What's the best practice to store events with NodeJs and MongoDB

I need to store all the database interactions(CRUD) in a collection, I research about but I didn't find a best way to do this. 我研究了所有数据库交互(CRUD)的集合,但我没有找到最佳的方法。

My app works with mongoose and I can use the pre/post hooks for insert this information in a collection. 我的应用程序可以使用猫鼬,并且可以使用前/后钩子将此信息插入集合中。 Mongoose Midleware 猫鼬Midleware

Are there are others options for implement this? 还有其他实现此目的的选择吗?

1)So technically if you're asking for catching the CRUD operations performed on mongodb ,Mongoose is an ORM(Object Relational Mapper) which does the job for you, but just in the conventional sort of Relational DB's like MSSQL Server ,the only hooks available to track the firing queries or DB transactions were triggers.Similarly,you can use triggers and listeners in mongodb ,check this package https://www.npmjs.com/package/mongo-triggers 1)因此从技术上讲,如果您要捕获在mongodb上执行的CRUD操作,Mongoose是一个ORM(对象关系映射器),可以为您完成工作,但仅在常规关系数据库(如MSSQL Server)中,唯一的钩子类似地,您可以在mongodb中使用触发器和侦听器,请检查此程序包https://www.npmjs.com/package/mongo-triggers

2) You can use something what mongo itself provides called as Tailable Cursors see the documentation https://docs.mongodb.com/manual/core/tailable-cursors/ 2)您可以使用mongo本身提供的称为“可拖尾光标”的功能,请参阅文档https://docs.mongodb.com/manual/core/tailable-cursors/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用MongoDB的NodeJS-实例化“ db”变量的最佳实践 - NodeJS with MongoDB - best practice to instantiate “db” variable nodejs需要使用'strict use'?还是node节点严格模式的最佳实践是什么? - nodejs need use 'strict use'?or what is the best practice of node's strict mode? JavaScript和活动 - 最佳实践 - JavaScript & Events - Best Practice 什么是最佳实践导航反应原生 - what's the best practice navigation react native WebSocket服务器的最佳实践是什么? - What is the best practice for WebSocket server(s)? 使用 react 调用 API 的最佳实践是什么 - What's the best practice to call API with react 订阅来自Iframe的事件,Angular的最佳做法是什么? - What is the best practice in Angular for subscribing to events coming from an Iframe? 呈现模态视图并绑定事件的最佳实践是什么? - What is the best practice for presenting a modal view and binding events to it? 创建可由 2 个角色 NodeJs 访问的路由的最佳实践是什么 - What is the best practice for creating a route that can be accessed by 2 roles NodeJs 通过猫鼬在mongodb中保存家谱的最佳实践是什么? - What will be the best practice to save family tree in mongodb via mongoose?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM