Accessing external Mongo database (node-red)

EDIT: I fixed it just after writing this message (I was passing the wrong name for the collection) but as I already have the message written I letf it here as reference for others with the same needs.

I’m learning meteor and I need to access data from a separate Mongo database (the node-red one) but I’m not getting results.

To access the external database I’m using the Meteor Remote Collection Package. I simply import it in my /api/nodered/nodered.js file where I define my collection:

import { RemoteCollection } from 'meteor/maxfi:remote-collection';
const NodeRedCollection = new RemoteCollection('CollectionName', 'mongodb://192.168.1.145:27017/nodered');
export default NodeRedCollection;

NodeRedCollection.allow({
  insert: () => false,
  update: () => false,
  remove: () => false,
});

NodeRedCollection.deny({
  insert: () => true,
  update: () => true,
  remove: () => true,
});

I publish the collection in the /api/nodered/server/publications.js

import { Meteor } from 'meteor/meteor';
import NodeRedCollection from '../nodered';

Meteor.publish('nodered.list', () => NodeRedCollection.find());

Then, in my container I try to fetch data from the collection:

import { composeWithTracker } from 'react-komposer';
import { Meteor } from 'meteor/meteor';
import NodeRedCollection from '../../api/nodered/nodered.js';
import NoderedList from '../components/NoderedList.js';
import Loading from '../components/Loading.js';

const composer = (params, onData) => {
  const subscription = Meteor.subscribe('nodered.list');
  if (subscription.ready()) {
    const nodered = NodeRedCollection.find().fetch();
    console.log('NoderedList Container:', nodered);
    onData(null, { nodered });
  }
};

export default composeWithTracker(composer, Loading)(NoderedList);

You can check: http://stackoverflow.com/questions/22054856/using-meteor-mongo-on-localhost-but-with-remote-database

$ MONGO_URL="mongodb://username:PASSWORD@hatch.mongohq.com:27017/test" meteor

Hi.

Yes, but this is not about using a remote Mongo database for meteor but about using an additional Mongo DB (regular Meteor’s Mongo DB is still the same, local or remote, but accessing also another DB at the same time).