0

Mongoose has a populate function to deref object by id.

model.find(...).populate('a_ref_field')

I want to create a function to deference automatically by data in the field which specify collection and id

e.g., foo: {col:'user',id:'54c5c5c13a0b4090451f8715'}

model.find(...).hyperPopulate('foo')

It seems mongoose allow users to create plugin. Is that possible to create a plugin to achieve this?

Jani Hyytiäinen
  • 5,293
  • 36
  • 45

1 Answers1

0

I found an example to do so

https://github.com/buunguyen/mongoose-deep-populate

Thanks