-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Aggregation $lookup problem #4819
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
Comments
I also discovered a second error with aggregation: {
match: {
user: {
$in: myPlantUsers.map(myPlantUser => myPlantUser.id)
}
}
}, Parse ends up making |
check this out #1908 (comment) hope it helps |
@flovilmart on a side note. This is kinda related to my comment #4743 (comment) Handling all paths will be a lot of work (recursive I dislike you). For instance #4743 needs some clean up but it does handle the 3 main paths which is a high priority. Can you look at it? |
You can also check my example at #4682 |
@dplewis @oallouch I can confirm this is working. Got a reasonable aggregation pipeline here: const pipeline = [
{
$project: {
userPointer: { $substr: ["$_p_user", 6, -1] },
_p_plant: 1
}
},
{
$lookup: {
from: "_User",
localField: "userPointer",
foreignField: "_id",
as: "tempUserPointer"
}
},
{ $unwind: "$tempUserPointer" },
{
$match: {
"tempUserPointer._p_currentRetailersGroup": /irtuvhei7dn$/
}
},
{
$group: {
_id: "$_p_plant",
count: { "$sum": 1 }
}
},
{ $sort: { count: -1 } },
{ $limit: 20 }
] Thanks for all the help! |
Just so you know, if you had a second $project after your $lookup (for instance) that wouldn't work (see #4682 ) |
Here we go again with my aggregation issues…
Issue Description
I want to do an aggregation query with a
$lookup
against a separate table, joining by_id
/objectId
, but because of the way Parse stores the relations (_User$0034nkjdfn
) I'm not able to do an equality match between localField and foreignField.Steps to reproduce
Collection
MyPlant
has a fielduser
(_p_user
) which is a pointer to the _User tableWhen I do an aggregate with the following pipeline:
it's trying to match the
_p_user: "_User$20gruknw98g4n"
with_id: "20gruknw98g4n"
which of course is not going to match.Is there any way around this?
Expected Results
Return a set of users in the 'users' field in the next pipeline stage.
Actual Outcome
Returns no users in the next pipeline stage.
Environment Setup
Server
Database
Logs/Trace
n/a
The text was updated successfully, but these errors were encountered: