سؤال

Consider the following:

>> meteor mongo
> show collections;
pages
system.indexes
> db.pages.count();
2
> db.pages.findOne();
{
    "_id" : "aec73d51-bb70-4e5b-90fe-a86bb5e5592f",
    "content" : "tuna fish sandwitches\nare super delicious! I mean really delicous",
    "created_at" : 1337353376284,
    "name" : "My first page"
}

But when I run the following from my meteor client:

> Pages = new Meteor.Collection('pages');
> Pages.findOne();

It yields undefined

Also note:

>> Pages.find().count();
>> 0

I have not disabled autopublish. Do I need to do something explicit to sync the db with the MiniMongo cache?

Meteor 0.3.6 | Mongo 2.0.2

هل كانت مفيدة؟

المحلول

Meteor doesn't autopublish everything in the Mongo database -- just the collections that are defined. So you just need the same declaration on the server that you already have on the client.

// client and server code
Pages = new Meteor.Collection('pages');
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top