Closed NeoTheThird closed 4 years ago
@NeoTheThird how are you remapping this in JS? I'm hitting hte same issue...
@NicholasAnthony have you tried updating to v0.2.7
? Also, new section of README:
If you're passing a Mongoose model rather than a collection, Mongoose will be used for data fetching. All transformations definded on that model (virtuals, plugins, etc.) will be applied to your data before caching, just like you would expect it. If you're using reference fields, you might be interested in checking out mongoose-autopopulate.
Since this lib uses the default client to talk to mongodb, mongoose references are not understood.
If i use a model like this:
Would return something like this:
Instead of what you would expect:
Obviously it's possible to work around this by re-mapping the object in js (which is ugly but works) or by using mongoose's methods rather than the default
findOneById
(which makes it impossible to use the built-in cache). Maybe it could be an option to use havefindOneById
actually use mongoose for find operations, if the constructor was passed a model instead of a collection? There would be more benefits, such as the possibility to cache Mongoose's virtuals.