-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
A query like this:
{
$aggregate: [
{$match: {species: 'sheep'}},
{$count: {$sum: 1}}
],
$comment: 'I am counting sheep'
}Results in an error message "Cursor methods can't run after collection method $aggregate" coming from:
Lines 1027 to 1031 in f746c0f
| if (collectionOperationKey && foundCursorMethod) { | |
| return ShareDbMongo.cursorAndCollectionMethodError( | |
| collectionOperationKey | |
| ); | |
| } |
The 3.x Mongo driver returns a cursor from db.collection.aggregate() and therefore allows further chaining, but the 2.x driver does not, which is why that check exists. One potential fix that would work with both versions - special-case aggregations to pass a comment/hint in the options when calling .aggregate().
Metadata
Metadata
Assignees
Labels
No labels