如何 - 单个 MongoDB 上的多个 Meteor 应用程序 - 相同的集合? [英] How to - multiple Meteor apps on single MongoDB - same collections?

查看:11
本文介绍了如何 - 单个 MongoDB 上的多个 Meteor 应用程序 - 相同的集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前有人问过这样的问题:如何在 Meteor 应用之间共享 MongoDB 集合?

This kind of question has been asked before: How can I share MongoDB collections between Meteor apps?

然而,答案并不明确.

我需要将 Meteor 公共应用和管理应用分开(出于多种原因,但主要是安全和代码管理).

I need to have a Meteor public app and the Administration app separate (for many reasons, but mainly security and code management).

使用已接受的答案:export MONGO_URL=mongodb://localhost:3002/meteor 似乎合理,但在另一个用户 'matthias' 下面指出当从另一个应用程序连接时,不会传输触发模型更改的事件跨这些应用程序.当然 mongoDB 实例本身并不知道这一点."

Using the accepted answer: export MONGO_URL=mongodb://localhost:3002/meteor seems reasonable, but below another user 'matthias' points out "When connecting from another app, events that trigger changes in the model would not be transported across those applications. The mongoDB instance itself of course isn't aware of that."

如何触发另一个"流星应用程序重新评估来自 MongoDB 的事件/触发器?意思很简单如果我对管理模块进行了更改,我如何才能使公共站点反映这些更改? 假设这就是本意.此外,此方法是否会丢失其他任何功能?

How does one trigger the 'other' meteor app to reevaluate the events/triggers from the MongoDB? Meaning simply if I make a change in the administration module, how can I make the public site reflect those changes? Assuming that is what was meant. Also is there any other functionality that will be lost by this method?

谢谢

推荐答案

答案是你什么都不用做.只要应用使用相同的数据库(由 MONGO_URL 标识),它们就会对数据的变化做出反应.

The answer is that you don't have to do anything. As long as the apps use the same database (as identified by the MONGO_URL), they will respond reactively to changes in the data.

事实上,将您的应用分为前端和后端是一个很好的策略,如本视频所述,为什么你应该拆分你的流星应用.

In fact separating your app into a front-end and a back-end is a good strategy, as outlined in this video, Why you should split your meteor app.

您甚至可以使用 mongo shell 来更新/插入/删除数据库中的文档,并且出版物会提取它们.

You can even use the mongo shell to update/insert/delete documents in the database, and the publications will pick them up.

这篇关于如何 - 单个 MongoDB 上的多个 Meteor 应用程序 - 相同的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆