node-mongo-seeds
node-mongo-seeds copied to clipboard
Can we set sequence to seed collections?
For example we have 2 collections medias and campaigns. In CampaignSchema we have medias field
medias: [{ type: ObjectId, ref: 'Media' }],
For population medias in campaigns, we need in campaigns.js file set medias documents _ids, but your seed invoke at first campaigns.js, after it medias.js file, so we cant use any media's _id.
So you're asking for a way to specify the order of the files to be seeded?
Yeah, something like that
Can you provide an example of some way you'd anticipate doing this?
for example we can set file name starting with 1., 2., 3., and so on. You should slice file name after dote. In my case I will set 1.media 2.campaign then seed will create media collection, then campaign. So I will able to use media's _id in campaign collection
In this example would you seed media
, then manually copy and paste the _id
's into campaign
and then seed just that file?
Bro suppose that I have 100 medias. So I need to set their all 100 _id manually? I think it's not the dynamic solution of our problem.
That's what i'm trying to get out of you. How exactly you'd expect to use this feature. So far you haven't given me a very concrete example.