Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/private/machines/count-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this comment?

if (err) { return exits.error(err); }

return exits.success(nativeResult);
Expand Down
9 changes: 9 additions & 0 deletions lib/private/machines/create-each-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it normally _id?


nativeResult.ops = s3q.newRecords;
var phRecords = nativeResult.ops;
try {
_.each(phRecords, function (phRecord){
Expand Down
3 changes: 3 additions & 0 deletions lib/private/machines/create-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ module.exports = {
// Otherwise, IWMIH we'll be sending back a record:
// ============================================

s3q.newRecord.id = nativeResult.insertedId;
nativeResult.ops = [s3q.newRecord];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike: Hmmm, why mutate nativeResult?
Should this be _id?


// 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```'));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down