afloyd / mongo-migrate

MIT License
159 stars 81 forks source link

Adding subdocuments while seeding data #22

Open gshubham opened 9 years ago

gshubham commented 9 years ago

I'm trying to add seed data using mongo-migrate. The problem I'm running into is that I want to add a subdocument as defined here. Subdocuments also have an _id field, but I'm not sure how to make that work. For example, I have a TimelineItem model which has a notes subdocument (which comes from noteSchema), but the only way I can add a new document to the timelineitems collection (and kind of emulating a subdocument) is to say timelineitems.insert({notes: [{//first note}, {//second note}]) but I don't think that captures the structure of the subdocument (like it doesn't have an _id etc.).

How should I make this work?