Details
-
Task
-
Resolution: Gone away
-
Minor - P4
-
None
-
None
Description
In this example:
the output is wrong (on the second line for _id 0). It should be:
MongoDB Enterprise > db.cakeSales.aggregate( [
|
... {
|
... $setWindowFields: {
|
... partitionBy: "$State", |
... sortBy: { OrderDate: 1 }, |
... output: {
|
... RecentOrders: {
|
... $push: "$OrderDate", |
... window: {
|
... range: [ "unbounded", -10 ], |
... unit: "month" |
... }
|
... }
|
... }
|
... }
|
... }
|
... ] )
|
{ "_id" : 4, "Type" : "strawberry", "OrderDate" : ISODate("2019-05-18T16:09:01Z"), "State" : "CA", "Price" : 41, "Quantity" : 162, "RecentOrders" : [ ] } |
{ "_id" : 0, "Type" : "chocolate", "OrderDate" : ISODate("2020-05-18T14:10:30Z"), "State" : "CA", "Price" : 13, "Quantity" : 120, "RecentOrders" : [ ISODate("2019-05-18T16:09:01Z") ] } |
{ "_id" : 2, "Type" : "vanilla", "OrderDate" : ISODate("2021-01-11T06:31:15Z"), "State" : "CA", "Price" : 12, "Quantity" : 145, "RecentOrders" : [ ISODate("2019-05-18T16:09:01Z") ] } |
{ "_id" : 5, "Type" : "strawberry", "OrderDate" : ISODate("2019-01-08T06:12:03Z"), "State" : "WA", "Price" : 43, "Quantity" : 134, "RecentOrders" : [ ] } |
{ "_id" : 3, "Type" : "vanilla", "OrderDate" : ISODate("2020-02-08T13:13:23Z"), "State" : "WA", "Price" : 13, "Quantity" : 104, "RecentOrders" : [ ISODate("2019-01-08T06:12:03Z") ] } |
{ "_id" : 1, "Type" : "chocolate", "OrderDate" : ISODate("2021-03-20T11:30:05Z"), "State" : "WA", "Price" : 14, "Quantity" : 140, "RecentOrders" : [ ISODate("2019-01-08T06:12:03Z"), ISODate("2020-02-08T13:13:23Z") ] } |
MongoDB Enterprise >
|