We need to migrate our current Mongodb 3.4 to version 3.6 but the recommendations don’t work.
Mongo says that you need to send the cursor option in aggregates, which I am doing like: someCollection.aggregate(pipeline, {cursor: {}})
Our aggregates work well using mongodb 3.4, but when trying to run them in 3.6, they don’t work.
The app is written with Meteor framework, version 1.2.0.2
The packages related to Mongodb are:
- dburles:mongo-collection-instances@0.3.4
- minimongo@1.0.10
- mongo@1.1.2
- mongo-id@1.0.1
- mongo-livedata@1.0.9
- npm-mongo@1.4.39_1
The pipeline for this example is:
let pipeline = [
{$match: {'contractor._id': contractorId, _id: {$ne: apptId}, start: {$lte: appt.start}}},
{$unwind: '$notes'},
{$sort: {start: -1, 'notes.creationDate': 1}}
];
Following are the options I’ve tried
#1:
var result = SalesAppointment.aggregate(pipeline, {cursor: {}});
return result;
#2:
var result = SalesAppointment.aggregate(pipeline, {cursor: {}});
return result.toArray();
#3:
var result = SalesAppointment.aggregate(pipeline, {cursor: {}});
return new Promise(function (resolve, reject) {
resolve(result.toArray());
});
#4:
var result = SalesAppointment.aggregate(pipeline, {cursor: {}});
return new Promise(function (resolve, reject) {
resolve(result);
});
#5:
let rawCol = SalesAppointment.rawCollection();
let aggregateQuery = Meteor.wrapAsync(rawCol.aggregate, rawCol);
return aggregateQuery(pipeline, {cursor: {}});
// RESULT: The previous options make the app to hang, it never gets to the return statement, and client never gets the promise resolved.
#6:
var result = SalesAppointment.rawCollection().aggregate(pipeline, {cursor: {}});
return result;
// RESULT: It returns an object with no data, only these properties: _readableState, readable, domain, _events, _maxListeners.
// In the backend it has these methods: explain, get, getOne, each, next, close, _read.
Thanks for your help.