diff --git a/lib/private/machines/count-records.js b/lib/private/machines/count-records.js index 5d0e7156b..889f309c7 100644 --- a/lib/private/machines/count-records.js +++ b/lib/private/machines/count-records.js @@ -61,7 +61,8 @@ module.exports = { // ╚═╝╚═╝╩ ╩╩ ╩╚═╝╝╚╝╩╚═╝╩ ╩ ╩ ╚═╝ └┴┘┴ ┴ ┴ ┴ ─┴┘└─┘ var db = inputs.connection; var mongoCollection = db.collection(tableName); - mongoCollection.find(mongoWhere).count(function countCb(err, nativeResult) { + mongoCollection.countDocuments(mongoWhere, function countCb(err, nativeResult) { + //mongoCollection.find(mongoWhere).count(function countCb(err, nativeResult) { if (err) { return exits.error(err); } return exits.success(nativeResult); diff --git a/lib/private/machines/create-each-record.js b/lib/private/machines/create-each-record.js index 57ad7cd83..e960e33ca 100644 --- a/lib/private/machines/create-each-record.js +++ b/lib/private/machines/create-each-record.js @@ -105,6 +105,15 @@ module.exports = { // ╠═╝╠╦╝║ ║║ ║╣ ╚═╗╚═╗ │││├─┤ │ │└┐┌┘├┤ ├┬┘├┤ │ │ │├┬┘ │││ └─┐ │ // ╩ ╩╚═╚═╝╚═╝╚═╝╚═╝╚═╝ ┘└┘┴ ┴ ┴ ┴ └┘ └─┘ ┴└─└─┘└─┘└─┘┴└──┴┘└─└─┘─┘ // Process record(s) (mutate in-place) to wash away adapter-specific eccentricities. + + var index = 0; + + _.each(s3q.newRecords, function (record){ + record.id = nativeResult.insertedIds[index]; + ++index; + }); + + nativeResult.ops = s3q.newRecords; var phRecords = nativeResult.ops; try { _.each(phRecords, function (phRecord){ diff --git a/lib/private/machines/create-record.js b/lib/private/machines/create-record.js index 22d390657..d55e2a28b 100644 --- a/lib/private/machines/create-record.js +++ b/lib/private/machines/create-record.js @@ -103,6 +103,9 @@ module.exports = { // Otherwise, IWMIH we'll be sending back a record: // ============================================ + s3q.newRecord.id = nativeResult.insertedId; + nativeResult.ops = [s3q.newRecord]; + // Sanity check: Verify that there is only one record. if (nativeResult.ops.length !== 1) { return exits.error(new Error('Consistency violation: Unexpected # of records returned from Mongo (in `.ops`). Native result:\n```\n'+util.inspect(nativeResult, {depth: 5})+'\n```')); diff --git a/package.json b/package.json index 112875582..e6b310d74 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "async": "3.2.4", "flaverr": "^1.10.0", "machine": "^15.2.2", - "mongodb": "3.7.3", + "mongodb": "4.8.1", "qs": "6.9.7" }, "devDependencies": {