Remote User Collection

Hi there!

I’m creating an app which connects to the database of an existing app in order to moderate carry out admin functions on said app. I’m connecting to the collections in the following way:

var database = new MongoInternals.RemoteCollectionDriver(mongodb://…);

Collection = new Mongo.Collection(‘collection’, {_driver: database});

This works great with most of the collections that I’m working with, but I’m struggling with users where I get the error “Error: A method named ‘/users/insert’ is already defined”. I understand that this is an issue with having a users collection on both apps. I see from here Remote Database has the same collection name that I could search through them using database.mongo.find(‘users’), but would like to be able to handle it with its own collection on the new app. is this at all possible?

Thanks in advance for any help !

Do this

Remote = DDP.connect('yourremoteservice');
Accounts.connection = Remote;
Meteor.users = new Mongo.Collection('users', Remote);

Thanks for your reply!

This appears to connect fine, but when I do .find().fetch()… no actual data comes out (when I know there is data on the other application). I can definitely see the connection coming in on the other server. This doesn’t seem to work for any of my collections, where as the method outlined above does…

Did you subscribe to the remote collection? You need to provide the Remote in the subscription call as well (documented with template.subscribe)

Thanks for the replies both, did get this working connecting via the server.

I would still prefer to do this by connecting straight to the database… is there any work around for users?

@flintchip Were you able to get this to work? I can’t seem to get any results using find() or fetch() either.