This repository was archived by the owner on Jun 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
This repository was archived by the owner on Jun 9, 2020. It is now read-only.
squash method not working like in the example #43
Copy link
Copy link
Open
Description
i'm working on a project that need capabilities that universe library have, but i had some trouble implementing the squash method.
This is my code, basically its the same with the example provided in the readme section
universe([
{date: "2011-11-14T16:17:54Z", quantity: 2, total: 190, tip: 100, type: "tab", productIDs: ["001"]},
{date: "2011-11-14T16:20:19Z", quantity: 2, total: 190, tip: 100, type: "tab", productIDs: ["001", "005"]},
{date: "2011-11-14T16:28:54Z", quantity: 1, total: 300, tip: 200, type: "visa", productIDs: ["004", "005"]},
{date: "2011-11-14T16:28:54Z", quantity: 3, total: 285, tip: 100, type: "tab", productIDs: ["001", "002", "005"]}
]).then(function(myUniverse){
myUniverse.query({
groupBy: 'type', // GroupBy the type key
select: {
$count: true, // Count the number of records
quantity: { // Create a custom 'quantity' column
$sum: 'quantity' // Sum the quantity column
},
},
// Limit selection to rows where quantity is greater than 50
filter: {
tip: {
$gt: 50
}
},
}).then(function(result) {
result.squash(null, null, {
count: '$sum',
quantity: {
sum: '$sum'
}
},'Total').then(function(resultq) {
console.log(JSON.stringify(resultq.data));
})
})
and this is the output
[{"key":"Total","value":{"count":4,"quantity":{"0":"sum"}}}]
what i was expecting from what i read in the example is something like the output below
[{"key":"Total","value":{"count":4,"quantity":{"sum":8}}}]
Am i calling the squash method the wrong way or is this a bug?
Sorry for my bad English.
Metadata
Metadata
Assignees
Labels
No labels