@@ -444,26 +444,24 @@ The following example is a pipeline similar to `distinct` grouping by name field
444
444
445
445
``` javascript
446
446
const pipelineObject = {
447
- group: { objectId : ' $name' }
447
+ $ group: { _id : ' $name' }
448
448
};
449
449
450
450
const pipelineArray = [
451
- { group: { objectId : ' $name' } }
451
+ { $ group: { _id : ' $name' } }
452
452
];
453
453
```
454
454
455
455
For a list of available operators please refer to [ Mongo Aggregate Documentation] ( https://docs.mongodb.com/v3.2/reference/operator/aggregation/ ) .
456
456
457
- * Note: Most operations in Mongo Aggregate Documentation will work with Parse Server, but ` _id ` doesn't exist. Please replace with ` objectId ` .
458
-
459
457
Group pipeline is similar to ` distinct ` .
460
458
461
459
You can group by a field.
462
460
463
461
``` javascript
464
462
// score is the field. $ before score lets the database know this is a field
465
463
const pipeline = [
466
- { group: { objectId : ' $score' } }
464
+ { $ group: { _id : ' $score' } }
467
465
];
468
466
const query = new Parse.Query (" User" );
469
467
query .aggregate (pipeline)
@@ -480,7 +478,7 @@ You can apply collective calculations like $sum, $avg, $max, $min.
480
478
``` javascript
481
479
// total will be a newly created field to hold the sum of score field
482
480
const pipeline = [
483
- { group: { objectId : null , total: { $sum: ' $score' } } }
481
+ { $ group: { _id : null , total: { $sum: ' $score' } } }
484
482
];
485
483
const query = new Parse.Query (" User" );
486
484
query .aggregate (pipeline)
@@ -496,7 +494,7 @@ Project pipeline is similar to `keys` or `select`, add or remove existing fields
496
494
497
495
``` javascript
498
496
const pipeline = [
499
- { project: { name: 1 } }
497
+ { $ project: { name: 1 } }
500
498
];
501
499
const query = new Parse.Query (" User" );
502
500
query .aggregate (pipeline)
@@ -512,7 +510,7 @@ Match pipeline is similar to `equalTo`.
512
510
513
511
``` javascript
514
512
const pipeline = [
515
- { match: { name: ' BBQ' } }
513
+ { $ match: { name: ' BBQ' } }
516
514
];
517
515
const query = new Parse.Query (" User" );
518
516
query .aggregate (pipeline)
@@ -528,7 +526,7 @@ You can match by comparison.
528
526
529
527
``` javascript
530
528
const pipeline = [
531
- { match: { score: { $gt: 15 } } }
529
+ { $ match: { score: { $gt: 15 } } }
532
530
];
533
531
const query = new Parse.Query (" User" );
534
532
query .aggregate (pipeline)
0 commit comments