Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
bb3d120
feat: upgrade docker-compose.yml from deprecated syntax
DominusKelvin Sep 29, 2023
b70cb73
chore: update mongodb driver to 6.1.0
DominusKelvin Sep 29, 2023
fa906e5
feat: remove deprecated client option
DominusKelvin Sep 29, 2023
5d1ef99
feat: update connect() to promise-based syntax
DominusKelvin Sep 29, 2023
6e918a5
chore: upgrade mongodb to 4.x and eslint to 8.x
DominusKelvin Oct 1, 2023
ec3dad7
chore: update ecmaVersion to 14
DominusKelvin Oct 1, 2023
c579e58
fix: use findOne to get back the newly created document
DominusKelvin Oct 1, 2023
15fe1c4
fix: use id not _id
DominusKelvin Oct 1, 2023
6318039
chore: update var declarations to const/let
DominusKelvin Oct 1, 2023
0ec5228
chore: change comment for .insertOne end
DominusKelvin Oct 1, 2023
2a39aad
feat: move to new syntax for insertMany and return records created vi…
DominusKelvin Oct 1, 2023
31e6a9a
feat: replace deprecated .count with .countDocuments
DominusKelvin Oct 1, 2023
1906335
chore: add return
DominusKelvin Oct 1, 2023
b301464
chore: move to mongodb 5 driver
DominusKelvin Oct 1, 2023
16506bd
chore: migrate drop to promies
DominusKelvin Oct 1, 2023
337fac4
fix: remove dropped from callback
DominusKelvin Oct 1, 2023
97f9810
Fixes typo
luislobo Oct 1, 2023
0636f4c
sum aggregation: Change from callback to promises
luislobo Oct 1, 2023
cf3b4fa
chore: reverting to callbacks until ns not found fix
DominusKelvin Oct 1, 2023
222d25f
fix: retain error handling for drop
DominusKelvin Oct 1, 2023
c913834
fix: add needed done()
DominusKelvin Oct 1, 2023
1ea5d21
feat: move sum-records to promise and const/let
DominusKelvin Oct 1, 2023
8bd1d34
feat: move avg-records to promise-based implementation
DominusKelvin Oct 1, 2023
12c669d
feat: change update-records to use promise and update test
DominusKelvin Oct 1, 2023
d327eea
feat: update find-record to use promise and update tests
DominusKelvin Oct 1, 2023
591f701
feat: update code for destroy-records and related tests
DominusKelvin Oct 1, 2023
9cb19f5
chore: change jsDocs and var to let/const
DominusKelvin Oct 2, 2023
5c0a0e3
chore: more cleanups for jsDoc
DominusKelvin Oct 2, 2023
3615b2c
feat: move createIndex to use promise
DominusKelvin Oct 2, 2023
a8c6f6a
chore: install @types/mocha
DominusKelvin Oct 2, 2023
8034502
chore: update JSDocs
DominusKelvin Oct 2, 2023
82168af
chore: move var to let/const
DominusKelvin Oct 2, 2023
ec5b6a6
chore: remove debugging console log
DominusKelvin Oct 2, 2023
d764465
feat: move to mongodb driver version 6 🎉
DominusKelvin Oct 2, 2023
a20b8fb
chore: install exact version of mongodb driver
DominusKelvin Oct 2, 2023
2cde4d1
fix: move to let/const
DominusKelvin Oct 2, 2023
69f725a
chore: fix JSDoc issues
DominusKelvin Oct 2, 2023
e5924a6
fix: move to let/const
DominusKelvin Oct 2, 2023
efe3235
fix: move to let/const
DominusKelvin Oct 2, 2023
6d41daa
fix: move to let/const
DominusKelvin Oct 2, 2023
c636498
fix: move to let/const
DominusKelvin Oct 2, 2023
ae9fbb9
fix: move to let/const
DominusKelvin Oct 2, 2023
d220a41
fix: move to let/const
DominusKelvin Oct 2, 2023
8d82b32
fix: move to let/const
DominusKelvin Oct 2, 2023
ea9d867
fix: move to let/const
DominusKelvin Oct 2, 2023
bef4089
fix: move to let/const
DominusKelvin Oct 2, 2023
cd4bee3
fix: move to let/const
DominusKelvin Oct 2, 2023
b951b05
fix: move to let/const
DominusKelvin Oct 2, 2023
0a29e4d
fix: move to let/const
DominusKelvin Oct 2, 2023
d6819fa
fix: move to let/const
DominusKelvin Oct 2, 2023
10ee8aa
chore: move to let/const
DominusKelvin Oct 2, 2023
2a04922
chore: move to let/const
DominusKelvin Oct 2, 2023
bb786c1
chore: move to let/const
DominusKelvin Oct 2, 2023
2147264
chore: move to let/const
DominusKelvin Oct 2, 2023
6cf7cc2
chore: move to let/const
DominusKelvin Oct 2, 2023
14c2d72
chore: add github actions for tests on ubuntu & windows and linting
DominusKelvin Oct 2, 2023
19e0d03
fix: update waterline to latest version
DominusKelvin Oct 2, 2023
55e7001
chore: upgrade mocha to latest version and adjust script
DominusKelvin Oct 2, 2023
61629ce
chore: update mocha config
DominusKelvin Oct 2, 2023
a8bf4fe
chore: change mongo image to 7
DominusKelvin Oct 3, 2023
e3872d7
chore: use modern docker compose command
DominusKelvin Oct 3, 2023
0574896
chore: update GitHub actions
DominusKelvin Oct 6, 2023
a5f8e12
chore: remove Travis and AppVeyor
DominusKelvin Oct 6, 2023
765c9d9
fix: stop returning id when fetch is disabled
DominusKelvin Oct 6, 2023
68f8b94
chore: remove outdated future comment
DominusKelvin Oct 6, 2023
056ccde
chore: revert back to var
DominusKelvin Nov 3, 2023
533f6d5
chore: revert changes
DominusKelvin Nov 3, 2023
998b2ea
chore: revert changes
DominusKelvin Nov 3, 2023
93d399f
chore: revert changes
DominusKelvin Nov 3, 2023
467b8ea
chore: revert changes
DominusKelvin Nov 3, 2023
cc52765
chore: revert changes
DominusKelvin Nov 3, 2023
e739209
chore: revert changes
DominusKelvin Nov 3, 2023
8370a46
chore: revert changes
DominusKelvin Nov 3, 2023
cc6d982
chore: revert changes
DominusKelvin Nov 3, 2023
5bdce05
chore: revert changes
DominusKelvin Nov 3, 2023
0463010
chore: revert changes
DominusKelvin Nov 3, 2023
17f1656
chore: revert changes
DominusKelvin Nov 3, 2023
a80f925
chore: revert changes
DominusKelvin Nov 3, 2023
94097b9
chore: revert changes
DominusKelvin Nov 3, 2023
1f058f7
chore: revert changes
DominusKelvin Nov 3, 2023
e0fb78d
chore: revert changes
DominusKelvin Nov 3, 2023
cb5699a
chore: revert changes
DominusKelvin Nov 3, 2023
0de57fe
chore: revert changes
DominusKelvin Nov 3, 2023
fba5a2a
chore: revert changes
DominusKelvin Nov 3, 2023
966450a
chore: revert changes
DominusKelvin Nov 3, 2023
66b1490
chore: revert changes
DominusKelvin Nov 4, 2023
96531c3
chore: revert changes
DominusKelvin Nov 4, 2023
cde8fcd
chore: revert changes
DominusKelvin Nov 4, 2023
c46934a
chore: revert changes
DominusKelvin Nov 4, 2023
4fd3e26
chore: revert changes
DominusKelvin Nov 4, 2023
59b4682
chore: revert changes
DominusKelvin Nov 4, 2023
915e89c
chore: revert changes
DominusKelvin Nov 4, 2023
e38df9a
chore: revert changes
DominusKelvin Nov 4, 2023
23aeb4a
chore: revert changes
DominusKelvin Nov 4, 2023
240e8b8
chore: revert changes
DominusKelvin Nov 4, 2023
ffff3f1
chore: revert changes
DominusKelvin Nov 4, 2023
640519c
chore: revert changes
DominusKelvin Nov 4, 2023
404a92d
chore: revert changes
DominusKelvin Nov 4, 2023
472c68e
chore: revert changes
DominusKelvin Nov 4, 2023
1057938
chore: revert changes
DominusKelvin Nov 4, 2023
b4a7a66
chore: revert changes
DominusKelvin Nov 4, 2023
b456449
chore: revert changes
DominusKelvin Nov 4, 2023
3fe2b84
chore: revert changes
DominusKelvin Nov 4, 2023
be326d9
chore: revert changes
DominusKelvin Nov 4, 2023
8feb197
chore: revert changes
DominusKelvin Nov 4, 2023
895fed0
chore: revert changes
DominusKelvin Nov 4, 2023
c54d1f7
chore: revert changes
DominusKelvin Nov 4, 2023
28b7cfd
chore: revert changes
DominusKelvin Nov 4, 2023
7203ae8
chore: revert changes
DominusKelvin Nov 4, 2023
3886dd7
chore: revert changes
DominusKelvin Nov 4, 2023
6f94e5f
chore: revert changes
DominusKelvin Nov 4, 2023
fd98a29
chore: revert changes
DominusKelvin Nov 4, 2023
6b6e8a8
chore: revert changes
DominusKelvin Nov 4, 2023
721095d
chore: revert changes
DominusKelvin Nov 4, 2023
5a3bf56
chore: revert changes
DominusKelvin Nov 4, 2023
0e857a3
chore: revert changes
DominusKelvin Nov 4, 2023
bb27cdd
chore: revert changes
DominusKelvin Nov 4, 2023
bca5215
chore: revert changes
DominusKelvin Nov 4, 2023
594afd6
chore: revert changes
DominusKelvin Nov 4, 2023
272b2fe
chore: revert changes
DominusKelvin Nov 4, 2023
a347693
chore: revert changes
DominusKelvin Nov 4, 2023
fb3e1d1
chore: revert changes
DominusKelvin Nov 4, 2023
800656d
chore: revert changes
DominusKelvin Nov 4, 2023
b9b7041
chore: revert changes
DominusKelvin Nov 4, 2023
838a0d6
chore: revert changes
DominusKelvin Nov 7, 2023
c814854
chore: revert changes
DominusKelvin Nov 7, 2023
624e784
chore: revert changes
DominusKelvin Nov 17, 2023
570881a
chore: revert changes
DominusKelvin Nov 17, 2023
3b6dc39
chore: revert changes
DominusKelvin Nov 17, 2023
1829c07
feat: use IIFE for implementing drop
DominusKelvin Nov 17, 2023
12ad6e0
chore: revert changes
DominusKelvin Nov 17, 2023
9291e9a
feat: use IIFE for createIndex
DominusKelvin Nov 17, 2023
13cfa65
chore: revert changes
DominusKelvin Nov 17, 2023
d1e3e15
feat: use IIFE for avg-records
DominusKelvin Nov 17, 2023
817a9e3
feat: use IIFE for avg-records
DominusKelvin Nov 17, 2023
b109abc
chore: revert changes
DominusKelvin Nov 17, 2023
529d82f
chore: revert changes
DominusKelvin Nov 17, 2023
772a717
feat: use IIFE for count-records
DominusKelvin Nov 17, 2023
11aacde
feat: use IIFE for create-record
DominusKelvin Nov 17, 2023
2cd402e
chore: revert changes
DominusKelvin Nov 17, 2023
fc73eaa
chore: revert changes
DominusKelvin Nov 17, 2023
da8e6fb
chore: revert changes
DominusKelvin Nov 17, 2023
5ecf56a
fix: make getting record created a one-liner
DominusKelvin Nov 17, 2023
8cd7034
fix: resolve not returning record(s)
DominusKelvin Nov 17, 2023
36a4e30
chore: revert changes
DominusKelvin Nov 17, 2023
507afd3
feat: use IIFE for create-manager
DominusKelvin Nov 17, 2023
b2795b5
feat: upgrade mongodb driver to 6.3.0
DominusKelvin Nov 17, 2023
f362416
chore: update connect comment
DominusKelvin Nov 17, 2023
162a5b4
chore: update comment link to use https
DominusKelvin Nov 17, 2023
5d5ea5c
feat: use IIFE for destroy-records
DominusKelvin Nov 17, 2023
76da6f8
chore: revert changes
DominusKelvin Nov 17, 2023
f6bc8f4
feat: use IIFE for find-records
DominusKelvin Nov 17, 2023
229c363
feat: use IIFE for sum-records
DominusKelvin Nov 17, 2023
fb34f80
chore: revert changes
DominusKelvin Nov 17, 2023
715f0d4
chore: revert changes
DominusKelvin Nov 17, 2023
0e5c0b0
chore: revert changes
DominusKelvin Nov 17, 2023
3de69b4
chore: revert changes
DominusKelvin Nov 17, 2023
bf4d976
chore: revert changes
DominusKelvin Nov 17, 2023
80296ac
feat: use IFFE for update-records
DominusKelvin Nov 17, 2023
c2e4ac0
chore: revert changes
DominusKelvin Nov 17, 2023
171fd4e
chore: revert changes
DominusKelvin Nov 17, 2023
f8e4972
Update run_mongodb.sh
DominusKelvin Nov 17, 2023
a9791c3
chore: revert changes
DominusKelvin Nov 17, 2023
c313798
Update run-standard-tests.js
DominusKelvin Nov 17, 2023
8322fa6
Update run-standard-tests.js
DominusKelvin Nov 17, 2023
6e0de20
Update build-std-adapter-method.js
DominusKelvin Nov 17, 2023
0e78883
Update build-std-adapter-method.js
DominusKelvin Nov 17, 2023
4b12cf6
chore: use IIFE for refactoring tests to promises
DominusKelvin Nov 17, 2023
852a17c
chore: revert changes
DominusKelvin Nov 17, 2023
77b24fc
chore: use IIFE for refactoring tests to promises
DominusKelvin Nov 17, 2023
0afecb9
chore: revert changes
DominusKelvin Nov 17, 2023
1ef1b8c
chore: use IIFE for refactoring tests to promises
DominusKelvin Nov 17, 2023
19e0869
chore: revert changes
DominusKelvin Nov 17, 2023
0de5119
chore: use IIFE for refactoring tests to promises
DominusKelvin Nov 17, 2023
6b989a3
chore: use IIFE for refactoring tests to promises
DominusKelvin Nov 17, 2023
3ccd0e7
chore: use IIFE for refactoring tests to promises
DominusKelvin Nov 17, 2023
60fb9c8
Update run-adapter-specific-tests.js
DominusKelvin Nov 17, 2023
5a30188
Update install_mongodb.sh
DominusKelvin Nov 17, 2023
1ad41ac
Delete scripts/travis/install_mongodb.sh
DominusKelvin Nov 17, 2023
acfd322
Delete scripts/travis/run_mongodb.sh
DominusKelvin Nov 17, 2023
49eeeb5
chore: revert changes
DominusKelvin Nov 17, 2023
0f856d4
Update install_mongodb.sh
DominusKelvin Nov 17, 2023
4558ab6
Update run_mongodb.sh
DominusKelvin Nov 17, 2023
856a9e1
chore: revert changes
DominusKelvin Nov 17, 2023
4b69023
chore: revert changes
DominusKelvin Nov 17, 2023
dff7767
update iife functions to return undefined instead of null, remove sec…
eashaw Nov 22, 2023
f190ffb
update comments
eashaw Nov 22, 2023
817c742
feat: add assertions for results returned from MongoDB
DominusKelvin Nov 23, 2023
c151a31
update node versions in CI config files
eashaw Nov 29, 2023
4cc13ca
update CI tests
eashaw Nov 29, 2023
a7c8f6f
run travis test on ubuntu 16, comment out incompatible node versions
eashaw Nov 29, 2023
49948b5
Update tests (localhost » 127.0.0.1)
eashaw Dec 4, 2023
ecf1f42
Revert test changes, update env variables in appveyor test to use ipv…
eashaw Dec 4, 2023
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
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ dist: xenial
language: node_js

node_js:
- "12"
- "14"
- "16"

# - "18"
# - "20"
env:
global:
- WATERLINE_ADAPTER_TESTS_URL=localhost/testdb
Expand Down
12 changes: 5 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@

# Test against these versions of Node.js.
environment:
WATERLINE_ADAPTER_TESTS_URL: localhost/testdb
WATERLINE_ADAPTER_TESTS_HOST: localhost
WATERLINE_ADAPTER_TESTS_URL: 127.0.0.1/testdb
WATERLINE_ADAPTER_TESTS_HOST: 127.0.0.1
WATERLINE_ADAPTER_TESTS_DATABASE: sails-mongo
NODE_ENV: test
matrix:
- nodejs_version: "10"
- nodejs_version: "12"
- nodejs_version: "14"
- nodejs_version: "16"
- nodejs_version: "18"
- nodejs_version: "20"

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js
# (Not sure what this is for, it's just in Appveyor's example.)
- ps: Install-Product node $env:nodejs_version
# Don't let npm send metrics as it creates a file in the .npm folder invalidating the cache every time
- npm config set send-metrics false
# Install declared dependencies
- npm install --no-audit

Expand Down
44 changes: 23 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
adapter:
image: node:12
volumes:
- $PWD:/home/node/sails-mongo
links:
- mongo
environment:
- WATERLINE_ADAPTER_TESTS_DATABASE=sails-mongo
- WATERLINE_ADAPTER_TESTS_URL=mongo/testdb
- WATERLINE_ADAPTER_TESTS_HOST=mongo
- NODE_ENV=test
user: node
working_dir: /home/node/sails-mongo
command:
- bash -c "npm test"
version: '3'
services:
adapter:
image: node:20
volumes:
- $PWD:/home/node/sails-mongo
links:
- mongo
environment:
- WATERLINE_ADAPTER_TESTS_DATABASE=sails-mongo
- WATERLINE_ADAPTER_TESTS_URL=mongo/testdb
- WATERLINE_ADAPTER_TESTS_HOST=mongo
- NODE_ENV=test
user: node
working_dir: /home/node/sails-mongo
command:
- bash -c "npm test"

mongo:
image: mongo:4.2
restart: always
command: "--logpath=/dev/null"
ports:
- "27017:27017"
mongo:
image: mongo:7
restart: always
command: "--logpath=/dev/null"
ports:
- "27017:27017"
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ module.exports = {

// Create the index on the Mongo collection.
// (https://docs.mongodb.com/manual/reference/method/db.collection.createIndex)
mongoCollection.createIndex(mongoSingleFieldIdxKeys, { unique: true }, function (err) {
(function(iifeDone) { mongoCollection.createIndex(mongoSingleFieldIdxKeys, { unique: true }).then(function() { iifeDone(); }).catch(function(err) {iifeDone(err);});})(function (err) {
if (err && !_.isError(err)) {
err = flaverr({raw: err}, new Error('Consistency violation: Expecting Error instance, but instead got: '+util.inspect(err)));
return next(err);
Expand Down Expand Up @@ -859,7 +859,7 @@ module.exports = {

// Drop the physical model (e.g. table/etc.)
var db = dsEntry.manager;
db.collection(tableName).drop(function (err) {
(function(iifeDone) { db.collection(tableName).drop().then(function() {iifeDone();}).catch(function(err) {iifeDone(err);});})(function (err) {
try {

if (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/machines/avg-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = {
}
], { cursor: {} });

cursor.toArray(function aggregateCb(err, nativeResult) {
(function(iifeDone) { cursor.toArray().then(function(nativeResult) { iifeDone(undefined, nativeResult); }).catch(function (err){iifeDone(err);}); })(function aggregateCb(err, nativeResult) {
if (err) { return exits.error(err); }

var mean = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/machines/count-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
// ╚═╝╚═╝╩ ╩╩ ╩╚═╝╝╚╝╩╚═╝╩ ╩ ╩ ╚═╝ └┴┘┴ ┴ ┴ ┴ ─┴┘└─┘
var db = inputs.connection;
var mongoCollection = db.collection(tableName);
mongoCollection.find(mongoWhere).count(function countCb(err, nativeResult) {
(function(iifeDone) { mongoCollection.countDocuments(mongoWhere).then(function(nativeResult) { iifeDone(undefined, nativeResult);}).catch(function(err) { iifeDone(err);});})(function countCb(err, nativeResult) {
if (err) { return exits.error(err); }

return exits.success(nativeResult);
Expand Down
33 changes: 22 additions & 11 deletions lib/private/machines/create-each-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {

fn: function (inputs, exits) {
// Dependencies
var util = require('util');
var _ = require('@sailshq/lodash');
var processNativeRecord = require('./private/process-native-record');
var processNativeError = require('./private/process-native-error');
Expand Down Expand Up @@ -82,7 +83,7 @@ module.exports = {
// if (s3q.meta && s3q.meta.logMongoS3Qs) {
// console.log('- - - - - - - - - -CREATE EACH: s3q.newRecords:',require('util').inspect(s3q.newRecords,{depth:5}),'\n');
// }
mongoCollection.insertMany(s3q.newRecords, function (err, nativeResult) {
(function(iifeDone){ mongoCollection.insertMany(s3q.newRecords).then(function(nativeResult) { iifeDone(undefined, nativeResult);}).catch(function(err) { iifeDone(err);});})(function(err, nativeResult) {
if (err) {
err = processNativeError(err);
if (err.footprint && err.footprint.identity === 'notUnique') {
Expand All @@ -97,23 +98,33 @@ module.exports = {
return exits.success();
}//-•

// Sanity check: Verify that IDs were sent back.
if (_.isUndefined(nativeResult.insertedIds) || !_.isObject(nativeResult.insertedIds)) {
return exits.error(new Error('Consistency violation: Unable to retrieve valid insertedIds from the result. This might indicate a consistency violation. Native result details:\n```\n' + util.inspect(nativeResult, {depth: 5}) + '\n```'));
}

var insertedIds = Object.values(nativeResult.insertedIds);

Copy link
Member

Choose a reason for hiding this comment

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

I think we should paste in (and slightly tweak) the assertion from here: https://github.com/balderdashy/sails-mongo/pull/499/files#diff-962fecaf7496f0dc0f4c49842e1e52f7035018902cd4530b86833883185c0166L106

that way we'll know if something changes in Mongo in the future and keep things just as easy to follow for migrating to future mongo driver releases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right @mikermcneil. I just added the assertions and tweaked it to match what we are checking.

// Otherwise, IWMIH we'll be sending back records:
// ============================================

// ╔═╗╦═╗╔═╗╔═╗╔═╗╔═╗╔═╗ ┌┐┌┌─┐┌┬┐┬┬ ┬┌─┐ ┬─┐┌─┐┌─┐┌─┐┬─┐┌┬┐┌─┌─┐─┐
// ╠═╝╠╦╝║ ║║ ║╣ ╚═╗╚═╗ │││├─┤ │ │└┐┌┘├┤ ├┬┘├┤ │ │ │├┬┘ │││ └─┐ │
// ╩ ╩╚═╚═╝╚═╝╚═╝╚═╝╚═╝ ┘└┘┴ ┴ ┴ ┴ └┘ └─┘ ┴└─└─┘└─┘└─┘┴└──┴┘└─└─┘─┘
// Process record(s) (mutate in-place) to wash away adapter-specific eccentricities.
var phRecords = nativeResult.ops;
try {
_.each(phRecords, function (phRecord){
processNativeRecord(phRecord, WLModel, s3q.meta);
});
} catch (e) { return exits.error(e); }

return exits.success(phRecords);

// Use the new record ID(s) to find the record(s) that were created.
(function(iifeDone){ mongoCollection.find({ _id: { $in: insertedIds } }).toArray().then(function(phRecords) { iifeDone(undefined, phRecords); }).catch(function(err) { iifeDone(err);});})(function(err, phRecords) {
if (err) {
return exits.error(err);
}
try {
_.each(phRecords, function (phRecord){
// Process record(s) (mutate in-place) to wash away adapter-specific eccentricities.
processNativeRecord(phRecord, WLModel, s3q.meta);
});
} catch (e) { return exits.error(e); }

return exits.success(phRecords);
});
}); // </ mongoCollection.insertMany() >

}
Expand Down
12 changes: 2 additions & 10 deletions lib/private/machines/create-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,8 @@ module.exports = {
var mongoUrl = _clientConfig.url;
_clientConfig = _.omit(_clientConfig, ['url', 'user', 'password', 'host', 'port', 'database']);

// Use unified topology. MongoDB node maintainers recommends this to be enabled
// https://github.com/mongodb/node-mongodb-native/releases/tag/v3.2.1
// Use new url parser to remove warnings
_clientConfig = Object.assign({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @mikermcneil this line has to go because the configs we are setting here has been deprecated and produces warnings.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this could be related to the ? error @eashaw mentioned (no real reason why I'm suggesting that, other than at a glance, I'm noticing useNewUrlParser, so maybe related?)

useNewUrlParser: true,
useUnifiedTopology: true
}, _clientConfig);

// http://mongodb.github.io/node-mongodb-native/3.5/api/MongoClient.html#.connect
NodeMongoDBNativeLib.MongoClient.connect(mongoUrl, _clientConfig, function connectCb(err, client) {
// https://mongodb.github.io/node-mongodb-native/6.3/classes/MongoClient.html#connect
(function(iifeDone){ NodeMongoDBNativeLib.MongoClient.connect(mongoUrl, _clientConfig).then(function(client){ iifeDone(undefined, client);}).catch(function(err) { iifeDone(err);});})(function(err, client){
if (err) {
return exits.error(err);
}
Expand Down
31 changes: 18 additions & 13 deletions lib/private/machines/create-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var db = inputs.connection;
var mongoCollection = db.collection(tableName);
mongoCollection.insertOne(s3q.newRecord, function (err, nativeResult) {
(function(iifeDone){ mongoCollection.insertOne(s3q.newRecord).then(function(nativeResult) { iifeDone(undefined, nativeResult);}).catch(function(err){ iifeDone(err);});})(function(err, nativeResult) {
if (err) {
err = processNativeError(err);
if (err.footprint && err.footprint.identity === 'notUnique') {
Expand All @@ -102,23 +102,28 @@ module.exports = {

// Otherwise, IWMIH we'll be sending back a record:
// ============================================

// 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```'));
// Sanity check: Verify that an ID was sent back.
if (_.isUndefined(nativeResult.insertedId)) {
return exits.error(new Error('Consistency violation: Unable to retrieve insertedId from the result. This might indicate a consistency violation. Native result details:\n```\n' + util.inspect(nativeResult, {depth: 5}) + '\n```'));
}


// ╔═╗╦═╗╔═╗╔═╗╔═╗╔═╗╔═╗ ┌┐┌┌─┐┌┬┐┬┬ ┬┌─┐ ┬─┐┌─┐┌─┐┌─┐┬─┐┌┬┐
// ╠═╝╠╦╝║ ║║ ║╣ ╚═╗╚═╗ │││├─┤ │ │└┐┌┘├┤ ├┬┘├┤ │ │ │├┬┘ ││
// ╩ ╩╚═╚═╝╚═╝╚═╝╚═╝╚═╝ ┘└┘┴ ┴ ┴ ┴ └┘ └─┘ ┴└─└─┘└─┘└─┘┴└──┴┘
// Process record (mutate in-place) to wash away adapter-specific eccentricities.
var phRecord = nativeResult.ops[0];
try {
processNativeRecord(phRecord, WLModel, s3q.meta);
} catch (e) { return exits.error(e); }

// Then send it back.
return exits.success(phRecord);
// Use the new record ID to find the record that was created.
(function(iifeDone) { mongoCollection.findOne({ _id: nativeResult.insertedId }).then(function(phRecord) { iifeDone(undefined, phRecord);}).catch(function(err) { iifeDone(err);});})(function(err, phRecord) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On the useNewUrlParser @mikermcneil that's no longer a supported config option in the newer version of the MongoDB driver. @eashaw can you confirm if that's the case for you?

if (err) {
return exits.error(err);
}
try {
// Process record (mutate in-place) to wash away adapter-specific eccentricities.
processNativeRecord(phRecord, WLModel, s3q.meta);
} catch (e) { return exits.error(e); }

// Then send it back.
return exits.success(phRecord);
});

}); // </ mongoCollection.insertOne() >
}
Expand Down
4 changes: 2 additions & 2 deletions lib/private/machines/destroy-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {
}

// Find matching records.
mongoCollection.find(mongoWhere).toArray(function findCb(err, nativeResult) {
(function(iifeDone) {mongoCollection.find(mongoWhere).toArray().then(function findCb(nativeResult) { iifeDone(undefined, nativeResult);}).catch(function(err) { iifeDone(err);});})(function findCb(err, nativeResult) {
if (err) { return proceed(err); }
return proceed(undefined, nativeResult);
});
Expand All @@ -104,7 +104,7 @@ module.exports = {
secondaryMongoWhere = {};
secondaryMongoWhere[pkColumnName] = { '$in': _.pluck(phRecords, pkColumnName) };
}
mongoCollection.deleteMany(secondaryMongoWhere, function deleteCb(err) {
(function(iifeDone) { mongoCollection.deleteMany(secondaryMongoWhere).then(function() { iifeDone();}).catch(function(err) { iifeDone(err);});})(function deleteCb(err) {
if (err) { return exits.error(err); }

if (!isFetchEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/machines/find-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
// ║ ║ ║║║║║║║║ ║║║║║║ ╠═╣ ║ ║╣ ││││ │ ├─┤ ││├┴┐
// ╚═╝╚═╝╩ ╩╩ ╩╚═╝╝╚╝╩╚═╝╩ ╩ ╩ ╚═╝ └┴┘┴ ┴ ┴ ┴ ─┴┘└─┘
// Find the documents in the db.
mongoDeferred.toArray(function findCb(err, nativeResult) {
(function(iifeDone) { mongoDeferred.toArray().then(function(nativeResult) { iifeDone(undefined, nativeResult);}).catch(function(err) { iifeDone(err);});})(function findCb(err, nativeResult) {
if (err) { return exits.error(err); }

// ╔═╗╦═╗╔═╗╔═╗╔═╗╔═╗╔═╗ ┌┐┌┌─┐┌┬┐┬┬ ┬┌─┐ ┬─┐┌─┐┌─┐┌─┐┬─┐┌┬┐┌─┌─┐─┐
Expand Down
2 changes: 1 addition & 1 deletion lib/private/machines/sum-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = {
}
], { cursor: {} });

cursor.toArray(function aggregateCb(err, nativeResult) {
(function(iifeDone) { cursor.toArray().then(function(nativeResult) { iifeDone(null, nativeResult);}).catch(function(err) { iifeDone(err, null);});})(function aggregateCb(err, nativeResult) {
if (err) { return exits.error(err); }

var sum = 0;
Expand Down
6 changes: 3 additions & 3 deletions lib/private/machines/update-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = {
// console.log('mongoWhere:',mongoWhere);
// console.log('typeof mongoWhere._id.$in[0]:',typeof mongoWhere._id.$in[0]);
// console.log('projection:',projection);
mongoCollection.find(mongoWhere, projection).toArray(function findCb(err, nativeResult) {
(function(iifeDone) { mongoCollection.find(mongoWhere, projection).toArray().then(function(nativeResult) { iifeDone(undefined, nativeResult);}).catch(function(err) { iifeDone(err);});})(function findCb(err, nativeResult) {
if (err) { return proceed(err); }
return proceed(undefined, _.pluck(nativeResult, pkColumnName));
});
Expand All @@ -126,7 +126,7 @@ module.exports = {
// console.log('- - - - - - - - - -UPDATE: secondaryMongoWhere:',secondaryMongoWhere, { '$set': s3q.valuesToSet });
// }

mongoCollection.updateMany(secondaryMongoWhere, { '$set': s3q.valuesToSet }, function updateManyCb(err) {
(function(iifeDone) { mongoCollection.updateMany(secondaryMongoWhere, { '$set': s3q.valuesToSet }).then(function() { iifeDone();}).catch(function(err) { iifeDone(err);});})(function updateManyCb(err) {
if (err) {
err = processNativeError(err);
if (err.footprint && err.footprint.identity === 'notUnique') {
Expand Down Expand Up @@ -158,7 +158,7 @@ module.exports = {


// Now re-fetch the now-updated records.
mongoCollection.find(secondaryMongoWhere).toArray(function (err, phRecords) {
(function(iifeDone) { mongoCollection.find(secondaryMongoWhere).toArray().then(function(phRecords) { iifeDone(undefined, phRecords);}).catch(function(err) { iifeDone(err);});})(function(err, phRecords) {
if (err) { return exits.error(err); }

// ╔═╗╦═╗╔═╗╔═╗╔═╗╔═╗╔═╗ ┌┐┌┌─┐┌┬┐┬┬ ┬┌─┐ ┬─┐┌─┐┌─┐┌─┐┬─┐┌┬┐┌─┌─┐─┐
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": "6.3.0",
"qs": "6.9.7"
},
"devDependencies": {
Expand Down
Loading