0

In Heroku, I have 2 apps. One client app(uses coffeescript and mongoose) and one admin app(uses javascript and mongoskin).

I would like to share one collection within these both apps, but cannot find out how to. I don't know if "sharding collections" is the route I should be researching to share a collection?...I would like some help figuring out a way to share a collection between 2 databases and 2 different heroku apps, or if it is possible.

I found some links on sharing databases, but I would like to share only collections within the databases. Here are some of the links I found, but haven't tested correctly since it deals with Meteor apps, not Heroku: How can I share MongoDB collections between Meteor apps?, DDP between two servers doesn't reconnect, Connect two Meteor applications using DDP

Community
  • 1
  • 1

1 Answers1

0

Of the 2 Heroku apps, one of them is the "owner" of the database for the collection you wish to share and is already pre-configured with the MONGODB_URI connection string for the database add-on. You would need to manually configure the 2nd Heroku app with the connection string for the database containing the collection you wish to share:

https://devcenter.heroku.com/articles/mongolab#connecting-to-existing-mlab-deployments-from-heroku

Note that this setup would share the entire database between the 2 add-ons. If you need restrict it to just a collection, you would need to create a database user for the 2nd Heroku app that only has access to the collection in question.

http://docs.mlab.com/connecting/#users

https://docs.mongodb.com/v3.0/core/security-user-defined-roles/

User defined role admin needs to be done through a client like the mongo shell - mLab's UI does not support them.

pneumee
  • 494
  • 3
  • 8