-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$lookup support #24
Comments
I have only looked at the Perhaps you can experiment with an implementation using the custom operators feature. Please feel free to send a PR |
Yup, it works with two collections. For the first glance it does not match |
This would be cool if data was provided through promises, then you could point to a restful URI wrapper to reference collections: {$lookup: {
from: collection('/api/users?active=true'), // <-- promis-ey thing,
localField: "email",
foreignField: "username"
}
} I'll play around with the custom operators... |
I thought a lot about this and it seems it would be better if we have 'collection' abstraction in I understand that it is a big shift and leads to a lot of refactoring, but it looks like the only good solution. We might implement this seamless way. Without changing existing API. Just add something like this: let usersData = [
// ...
]
let users = Mingo.collection('users', usersData)
users.find( ... )
users.aggregate( ... )
// let data = users.toArray() - to get the array back
// or
// let users = Mingo.collection('users') - if it already exists in Mingo
// and we just want to get a link What do you think guys? It isn't a heavy solution, is it? |
This did cross my mind a while ago but I was deterred from going with it. My concern is that it makes Mingo begin to look like a mini MongoDB database which I want to avoid as much as possible. I believe someone mentioned a similar project Once we begin to hold collection references it opens up a can of worms of rules regarding immutability guarantees etc. I feel that is more suitable for an adjacent project which perhaps uses Mingo for the querying. Have you had any success implementing You may have to modify the original structure a bit to make it work by passing in the extra collection. It is ok to break a few rules to get Mingo to work for its purpose so the result need not be exactly as in MongoDB. Let's keep the discussion going. I think we will come to an acceptable solution. Thanks for pushing. |
Taking another look at this issue, it hit me that a collection abstraction is not necessary at all if we are willing to break a bit of MongoDB convention. The Example: {
$lookup:
{
from: <collection to join>, // this will be an Array
localField: <field from the input documents>,
foreignField: <field from the documents of the "from" collection>,
as: <output_field>
}
} In fact this is similar to what @justsml suggested above but will put the implementation of data sourcing outside of Mingo.
Any comments? |
Added in commit 6ae6509 |
Is new mongo 3.2
$lookup
support planned?The text was updated successfully, but these errors were encountered: