These are notes on accessing a MongoDB from two Meteor apps as well as sharing User authentication between multiple apps.
Option #1 - There's a brief Stackoverflow discussion on this. Start the main app that owns the database:
meteor
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
There's a good post on this here (Mar 2015). Start the main application DB.
meteor
Setup access to the user collection from the second application:
var database = new MongoInternals.RemoteCollectionDriver( "mongodb://<server>:3001/meteor"); MyCollection = new Mongo.Collection("Users", { _driver: database });
From this Stackoverflow post (Aug 2013):
var remote = DDP.connect('http://server1.com/'); Items = new Meteor.Collection('items', remote); remote.subscribe('items', function() { var items = Items.find(); console.log(items.count()); // get 1 });
From this Stackoverflow post (Nov 2013):
var DDPConnection = DDP.connect(); DDPConnection.call("login", {"password":"qwerty", "user" : { "email":"email@email.com" } }, function(err,result) { //Check result } );
DDP connect is documented here.