Shared DB Access and User Authentication with Meteor

Posted by {"display_name"=>"greg", "login"=>"greg", "email"=>"", "url"=>""} on February 27, 2016 · 1 min read

These are notes on accessing a MongoDB from two Meteor apps as well as sharing User authentication between multiple apps.

Sharing the Same Database

Option #1 - There's a brief Stackoverflow discussion on this. Start the main app that owns the database:


The database is now accessible on port 3001.
Start the second app, pointing it at the first apps DB:

MONGO_URL="mongodb://localhost:3001/meteor" meteor --port 3002

Accessing a Collection from Another DB

Option #1 -

There's a good post on this here (Mar 2015). Start the main application DB.


Setup access to the user collection from the second application:

var database = new MongoInternals.RemoteCollectionDriver(
MyCollection = new Mongo.Collection("Users", { _driver: database });

Option #2 -

From this Stackoverflow post (Aug 2013):

var remote = DDP.connect('');
Items = new Meteor.Collection('items', remote); 

remote.subscribe('items', function() {
  var items = Items.find();
  console.log(items.count());  // get 1         

Logging In Using Another App

From this Stackoverflow post (Nov 2013):

var DDPConnection = DDP.connect();"login", {"password":"qwerty",
    "user" : { "email":"" }
    function(err,result) {
        //Check result

DDP Connect

DDP connect is documented here.