Using Multiple Mongodb Databases with Angular2-Meteor [Solved]

I am using Angular2-Meteor in my project.

However, I want to connect to multiple MongoDb Databases.

If I´m not using Angular, I can connect remotely using:

export const conn= new MongoInternals.RemoteCollectionDriver(“mongodb://IP:27017/DB”);
export const Tasks= new Mongo.Collection(“CollectionName”,{_driver: conn});
Meteor.publish(‘tasks’, function tasksPublication() {
return Tasks.find({},{limit:10});

So,I am using angular, and I can´t use this method because I got the error:

'cannot find MongoInternals.'

How can I connect to multiple MongoDb´s using Angular2-Meteor ???

Which frontend framework really shouldn’t matter for this.
You can only use MongoInternals on the server though. Could that be your problem?

Yes. I understand. But, when I adopted the angular2 meteor, I change the language to typescript.
Then, In my server folder, I have the main.ts with the Meteor.startup.
When I try to use this code with MongoInternals in the server folder, inside Meteor.startup, I received this error:
‘cannot find MongoInternals’.

Hmm, maybe you need to import it when using Typescript?

Probably yes, but I don’t know how to do that.

import {MongoInternals} from 'mongo' maybe?

Putting this in ./server/main.ts:
import { MongoInternals } from 'meteor/mongo';

I got this message:

Module ‘“meteor/mongo”’ has no exported member ‘MongoInternals’.

Oh, I guess the Mongo package is not setup with exports. Hmm, what if you do import 'metor/mongo' ? I think that should give you access to it’s globals. If that doesn’t work maybe you’ll have to download the package and edit it to add exports.

I solved this problem!
Thank you for your help…

In fact, I was trying to create a MongoInternals inside a TypeScript. This does not work.

The solution is quite simple. I create a group of Meteor.methods with all functions that I need. So, in the Typescript, I create a Service that just use them.

/*Service */

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import '../methods/database.js';

export class DatabaseService {

    private Conn: any;

    constructor() {        

     public newConnection(dbUrl) {'connectDB', dbUrl, function(err, response) {
           this.Conn= response;

     public setConn(conn) {
         this.Conn= conn;

     public getConn(): any {
         return this.Conn;


/* Methods */

      connectDB: function(dataUrl) {
        conn = new MongoInternals.RemoteCollectionDriver(dataUrl);
        return conn;

/*main . ts */`

Meteor.startup(() => {
    var db = new DatabaseService();
    var dbConn= db.newConnection(url);

Hi eloy( @eloymojr ) I need your help,
i am using angular2-meteor in my project,Now i want to connect Multiple mongodb database.

    MONGO_URL="mongodb://localhost:27017/DB_name" and

Another one mongodb is MONGO_URL=“mongodb://localhost:27018/DB_name”

Hi sathishfreaz.

To the first database you can connect configuring the $ MONGO_URL string. Then, you can use the first database creating collection with MongoObservable.

However, to use the second database, you should connect using a Remote Collection. So, you need to use the ‘MongoInternals’ to create a Remote Collection Driver.

However, the typescript does not have the ‘MongoInternals’ function mapped.
So, the solution is to create in the Server, meteor methods to access via MongoInternals the second database.

Then, as I showed, I create one method (called connectionDB) in server (I’m not using the typescript), and after, I create a Service (In typescript) that makes use of this method passing as argument the url of DB.

Using this solution, you can connect in multiple database, just changing the dbUrl argument of service.