Reputation: 17332
I have connected two meteor applications via DDP. I expected to get the DB data also on the second service application, but I don't get any data. As both is running on server side I didn't do any subscription - which I think I don't have to in this example.
What am I doing wrong?
meteor
(which should load mongodb on port 3001)MONGO_URL=mongodb://localhost:3001/mydb meteor --port 3100
Web (main) /server/main.js
Examples = new Mongo.Collection('examples');
var serviceConn = DDP.connect("http://localhost:3100");
console.log(Examples.find().count()); // Returns 21
Service 1 /server/main.js
Examples = new Mongo.Collection('examples');
console.log(Examples.find().count()); // Returns 0 !
So why can't I get the collection data on the service application as it gives me 0 results?
Upvotes: 2
Views: 53
Reputation: 7748
Try this in your service application:
const con = DDP.connect('http://localhost:3000');
Examples = new Mongo.Collection('examples', {
connection: con,
});
console.log(Examples.find().count());
Remember to start your main application first
Upvotes: 3