Can't Migrate Mongodb from version 3.4 to 3.6 using Meteor 1.2.0.2

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.

My first thought is that you’ll need to update the npm-mongo package, which Meteor probably won’t let you do with that Meteor version. The MongoDB driver compatibility table says for 3.6 you need the npm driver version >= 3.0
You might need to copy a newer version into /packages/npm-mongo and update the version it pulls in from npm to match the MongoDB version.

My second thought is that raw Mongo is async, and the older driver probably uses callbacks rather than returning a promise. But this is just a guess
EDIT: the meteor/npm-mongo fork looks like it doesn’t return at all, only uses callbacks. Not sure about the official driver

1 Like