Closed gregfrasco closed 7 years ago
Thanks for creating an issue and sharing your ideas about this. I don't think this fits well with the current design of mongo-models
.
Also $lookup
is used via the aggregate
method on a collection. We do expose an aggregate
method. See the docs here: https://github.com/jedireza/mongo-models/blob/master/API.md#aggregatepipeline-options-callback
So $lookup
would just be part of the pipeline
argument we pass to aggregate
. I think the proper solution would be to wait for a type conversion mechanism as discussed here:
https://jira.mongodb.org/browse/SERVER-24947.
I'll close this issue for now, but please feel free to continue the conversation and/or create new issues in the future. Thanks again for being active with the project.
Minor note: Your function is named lockupById
when I think you meant lookupById
.
MongoDB lookup commands do not support lookup with object id and a string id. Reference ticket. Most of my other collections have a userId field that is a string ID, and maybe others do too. I created a function to do something similar.
I can create tests and then a pull request, if interested. Also intrested in adding a pagedFind Lookup as well because that would help me more in my porjects. Lookup By Id Function
Usage
User Collection:
Example Collection (Mood):
Schema:
Collection:
Function
Example
returns
you can also add filters and options like this:
returns