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
Operations like $multiply are confined to the stage it's coded on ($group in this case).
$multiply
$group
We should extract all operations and allow them to be called from many different places, like on $project phase.
$project
One example from MongoDB with our orders collection:
orders
test> db.orders.aggregate([{ $project: { array: [ '$name', { $multiply: [ '$price', '$quantity'] }] } }]) [ { _id: 0, array: [ 'Pepperoni', 190 ] }, { _id: 1, array: [ 'Pepperoni', 400 ] }, { _id: 2, array: [ 'Pepperoni', 630 ] }, { _id: 3, array: [ 'Cheese', 180 ] }, { _id: 4, array: [ 'Cheese', 650 ] }, { _id: 5, array: [ 'Cheese', 140 ] }, { _id: 6, array: [ 'Vegan', 170 ] }, { _id: 7, array: [ 'Vegan', 180 ] } ]
And the data:
db.orders.insertMany([ { name: "Pepperoni", size: "small", price: 19, quantity: 10, date: ISODate("2021-03-13T08:14:30Z") }, { name: "Pepperoni", size: "medium", price: 20, quantity: 20, date: ISODate("2021-03-13T09:13:24Z") }, { name: "Pepperoni", size: "large", price: 21, quantity: 30, date: ISODate("2021-03-17T09:22:12Z") }, { name: "Cheese", size: "small", price: 12, quantity: 15, date: ISODate("2021-03-13T11:21:39.736Z") }, { name: "Cheese", size: "medium", price: 13, quantity: 50, date: ISODate("2022-01-12T21:23:13.331Z") }, { name: "Cheese", size: "large", price: 14, quantity: 10, date: ISODate("2022-01-12T05:08:13Z") }, { name: "Vegan", size: "small", price: 17, quantity: 10, date: ISODate("2021-01-13T05:08:13Z") }, { name: "Vegan", size: "medium", price: 18, quantity: 10, date: ISODate("2021-01-13T05:10:13Z") }]);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Operations like
$multiply
are confined to the stage it's coded on ($group
in this case).We should extract all operations and allow them to be called from many different places, like on
$project
phase.One example from MongoDB with our
orders
collection:And the data:
The text was updated successfully, but these errors were encountered: