meteor/mongodb: Use different DB for authentication & read/write

痴心易碎 提交于 2019-12-24 16:02:10

问题


meteor allows to specify the DB using the env variable MONGO_URL:

"mongodb://user:password@host:port/meteorDB"

Meteor will then automatically use the "meteorDB" database to authenticate against and all collections will refer to this database and read/write to it.

However, I use mongodb cloud manager to setup my users. It saves all users to the admin DB rather than having separate users saved in each database. I would like to use the "admin" DB for authentication and the "meteorDB" for data storage. Is this possible?


回答1:


Yep, here's a code snippet of how to tie a collection to a different MongoDB URL:

var db = new MongoInternals.RemoteCollectionDriver("<ONE OF YOUR DBS>");
MyCollection = new Mongo.Collection("<YOUR COLLECTION>", { _driver: db });


来源:https://stackoverflow.com/questions/34979274/meteor-mongodb-use-different-db-for-authentication-read-write

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!