We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
import { aggregate } from "mingo"; import "mingo/init/system"; function main() { const result = aggregate( [{ "skills":{ "data": [ { "name":"Respiratory Therapst", "categories":{ "data":[ { "name": "Healthcare" } ] } }, { "name":"Phlebotomy", "categories":{ "data":[ { "name": "Skills (N-R) - DNU for Postings" }, { "name": "Healthcare" } ] } } ] }, "location" : 'abcd' }], [ { "$project" : { "specialties" : { "$reduce" : { "input" : "$skills.data", "initialValue" : [], "in" : { "$concatArrays" : [ "$$value", { "$map" : { "input" : "$$this.categories.data", "as" : "category", "in" : { "skill" : "$$this.name", "category" : "$$category.name" } } } ] } } }, "location": "$location" } } ]); console.log(result[0]); } main();
Expected Result
{ "specialties" : [ { "skill" : "Respiratory Therapst", "category" : "Healthcare" }, { "skill" : "Phlebotomy", "category" : "Skills (N-R) - DNU for Postings" }, { "skill" : "Phlebotomy", "category" : "Healthcare" } ], "location" : "abcd" }
Actual Result
{ specialties: [ { skill: 'Healthcare', category: 'Healthcare' }, { skill: 'Skills (N-R) - DNU for Postings', category: 'Skills (N-R) - DNU for Postings' }, { skill: 'Healthcare', category: 'Healthcare' } ] }
When using $map inside a $reduce it is returning incorrect results and causing fields projected after the reduce map to be undefined.
The text was updated successfully, but these errors were encountered:
e79f30a
No branches or pull requests
Expected Result
Actual Result
When using $map inside a $reduce it is returning incorrect results and causing fields projected after the reduce map to be undefined.
The text was updated successfully, but these errors were encountered: