peerlibrary / meteor-peerdb

Reactive database layer with references, generators, triggers, migrations, etc.
http://atmospherejs.com/peerlibrary/peerdb
BSD 3-Clause "New" or "Revised" License
130 stars 15 forks source link

Document.updateAll not updating references #31

Closed juho closed 9 years ago

juho commented 9 years ago

I want to have some fixture data for local development which I’m inserting like so (in server/fixtures.js):

 var questionId0 = Question.documents.insert({
   title: "Title text"
 });

 var testAnswerId0 = Answer.documents.insert({
   question: {
     _id: questionId0
   }
 });

My PeerDB class definition for Answer has the Question field referenced:

       question: Answer.ReferenceField(Question, ['title'])

I see the changes being made to the answer object when I manually update the Question in the Mongo CLI, but running Document.updateAll(); after doing my insertions in fixtures.js does not seem to construct the couple of references I’d want to have while booting up.

juho commented 9 years ago

Ah, got it working - was something dumb like I thought. It was outside my Meteor.startup().

mitar commented 9 years ago

Yes, it should be after you see that observes are running.