seanemmer / mongoose-seed

Seed data population for Mongoose
MIT License
52 stars 33 forks source link

Ref other models #17

Closed FrenchBully closed 7 years ago

FrenchBully commented 7 years ago

Does this currently support referencing other model schemas within a model?

seanemmer commented 7 years ago

This should work as long as you load those models as well.

rubenvde commented 5 years ago

Can you please explain this for me? I followed the readme and my var data array is looking something like this:

{
  'model': 'Section',
  'documents': [
  {
        "title": "Bla",
  },
  ]
},
{
  'model': 'Project',
  'documents': [
    {
      'title': 'Test project',
      'sections': [/* INSERT SECTION HERE */],
    },
  ]
}

How is it possible to insert the first 'Section' to the 'Project' model where it's referenced in the sections attribute?

I'm sad to see that there isn't any test written using the "ref" attribute.