Skip to content

Commit

Permalink
Merge pull request #549 from 3z3qu13l/master
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
raymondfeng authored Oct 31, 2019
2 parents b3b5e6a + b77dc55 commit d660cab
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 236 deletions.
8 changes: 4 additions & 4 deletions example/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Customer.destroyAll(function(err) {
function(err, customer2) {
Customer.find({where: {'emails.email': '[email protected]'}}, function(
err,
customers
customers,
) {
g.log('{{Customers}} matched by {{emails.email}} %s', customers);
});

Customer.find({where: {'emails.0.label': 'work'}}, function(
err,
customers
customers,
) {
g.log('{{Customers}} matched by {{emails.0.label}} %s', customers);
});
Expand All @@ -80,8 +80,8 @@ Customer.destroyAll(function(err) {
ds.disconnect();
});
});
}
},
);
}
},
);
});
4 changes: 2 additions & 2 deletions leak-detection/mongodb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('mongodb', function() {
{content: 'Buy milk'},
{content: 'Buy cheese'},
],
done
done,
);
});

Expand Down Expand Up @@ -86,7 +86,7 @@ describe('mongodb', function() {
{content: 'Buy milk'},
{content: 'Buy cheese'},
],
done
done,
);
});
});
Expand Down
48 changes: 24 additions & 24 deletions lib/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function ObjectID(id) {
// hex string. For LoopBack, we only allow 24-byte hex string, but 12-byte
// string such as 'line-by-line' should be kept as string
if (ObjectIdValueRegex.test(id)) {
return bson.ObjectID(id);
return new bson.ObjectID(id);
} else {
return id;
}
Expand Down Expand Up @@ -310,15 +310,15 @@ MongoDB.prototype.connect = function(callback) {
g.error(
'{{MongoDB}} connection is failed: %s %s',
self.settings.url,
err
err,
);
}
if (callback) callback(err);
}

new mongodb.MongoClient(self.settings.url, validOptions).connect(function(
err,
client
client,
) {
if (err) {
onError(err);
Expand All @@ -336,7 +336,7 @@ MongoDB.prototype.connect = function(callback) {
}
self.db = client.db(
url.dbName || self.settings.database,
url.db_options || self.settings
url.db_options || self.settings,
);
if (callback) callback(err, self.db);
});
Expand Down Expand Up @@ -486,7 +486,7 @@ MongoDB.prototype.execute = function(modelName, command) {
'Connection not established - MongoDB: model=%s command=%s -- error=%s',
modelName,
command,
err
err,
);
}
doExecute();
Expand Down Expand Up @@ -532,7 +532,7 @@ MongoDB.prototype.execute = function(modelName, command) {
debug('MongoDB: model=%s command=%s', modelName, command, args);
return collection[command].apply(collection, args);
},
callback
callback,
);
}
};
Expand Down Expand Up @@ -797,7 +797,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate(
modelName,
data,
options,
callback
callback,
) {
const self = this;
if (self.debug) {
Expand Down Expand Up @@ -852,7 +852,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate(
if (callback) {
callback(err, self.fromDatabase(modelName, object), info);
}
}
},
);
};

Expand Down Expand Up @@ -1112,7 +1112,7 @@ function convertToMeters(distance, unit) {
console.warn(
'unsupported unit ' +
unit +
", fallback to mongodb default unit 'meters'"
", fallback to mongodb default unit 'meters'",
);
return distance;
}
Expand Down Expand Up @@ -1390,7 +1390,7 @@ MongoDB.prototype.all = function all(modelName, filter, options, callback) {
objs,
filter.include,
options,
callback
callback,
);
} else {
callback(null, objs);
Expand All @@ -1409,7 +1409,7 @@ MongoDB.prototype.destroyAll = function destroyAll(
modelName,
where,
options,
callback
callback,
) {
const self = this;
if (self.debug) {
Expand Down Expand Up @@ -1473,7 +1473,7 @@ MongoDB.prototype.replaceById = function replace(modelName, id, data, options, c
const oid = this.coerceId(modelName, id, options);
this.replaceWithOptions(modelName, oid, data, {upsert: false}, function(
err,
data
data,
) {
cb(err, data);
});
Expand Down Expand Up @@ -1501,7 +1501,7 @@ MongoDB.prototype.replaceWithOptions = function(modelName, id, data, options, cb
data = self.toDatabase(modelName, data);
this.execute(modelName, 'replaceOne', {_id: id}, data, options, function(
err,
info
info,
) {
debug('updateWithOptions.callback', modelName, {_id: id}, data, err, info);
if (err) return cb && cb(err);
Expand Down Expand Up @@ -1542,7 +1542,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs(
id,
data,
options,
cb
cb,
) {
const self = this;

Expand Down Expand Up @@ -1593,7 +1593,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs(
if (cb) {
cb(err, object);
}
}
},
);
};

Expand All @@ -1616,7 +1616,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll(
where,
data,
options,
cb
cb,
) {
const self = this;
if (self.debug) {
Expand Down Expand Up @@ -1650,7 +1650,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll(
if (cb) {
cb(err, {count: affectedCount});
}
}
},
);
};

Expand Down Expand Up @@ -1801,13 +1801,13 @@ MongoDB.prototype.autoupdate = function(models, cb) {
.createIndex(
index.fields || index.keys,
index.options,
indexCallback
indexCallback,
);
},
modelCallback
modelCallback,
);
},
cb
cb,
);
} else {
self.dataSource.once('connected', function() {
Expand Down Expand Up @@ -1854,7 +1854,7 @@ MongoDB.prototype.automigrate = function(models, cb) {
'Error dropping collection %s for model %s: ',
collectionName,
modelName,
err
err,
);
if (
!(
Expand All @@ -1879,7 +1879,7 @@ MongoDB.prototype.automigrate = function(models, cb) {
return cb && cb(err);
}
self.autoupdate(models, cb);
}
},
);
} else {
self.dataSource.once('connected', function() {
Expand Down Expand Up @@ -2064,14 +2064,14 @@ function optimizedFindOrCreate(modelName, filter, data, options, callback) {
if (filter && filter.include) {
self._models[modelName].model.include([value], filter.include, function(
err,
data
data,
) {
callback(err, data[0], created);
});
} else {
callback(null, value, created);
}
}
},
);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

exports.getDistanceBetweenPoints = function getDistanceBetweenPoints(
point1,
point2
point2,
) {
const R = 6371; // Radius of the earth in km
const dLat = deg2rad(point2.lat - point1.lat); // deg2rad below
Expand All @@ -20,9 +20,8 @@ exports.getDistanceBetweenPoints = function getDistanceBetweenPoints(
Math.sin(dLon / 2);

const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
const d = R * c; // Distance in km

return d;
return R * c; // Distance in km;
};

function deg2rad(deg) {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
],
"license": "MIT",
"dependencies": {
"async": "^2.6.1",
"async": "^3.1.0",
"bson": "^1.0.6",
"debug": "^3.1.0",
"debug": "^4.1.0",
"loopback-connector": "^4.5.0",
"mongodb": "^3.2.4",
"strong-globalize": "^4.1.1"
Expand All @@ -39,17 +39,17 @@
"benchmark": "^2.1.4",
"bluebird": "^3.5.4",
"coveralls": "^3.0.4",
"eslint": "^5.1.0",
"eslint": "^6.6.0",
"eslint-config-loopback": "^13.0.0",
"juggler-v3": "file:./deps/juggler-v3",
"juggler-v4": "file:./deps/juggler-v4",
"loopback-datasource-juggler": "^3.0.0 || ^4.0.0",
"mocha": "^5.2.0",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"rc": "^1.2.8",
"semver": "^5.5.1",
"semver": "^6.3.0",
"should": "^13.2.1",
"sinon": "^6.1.3"
"sinon": "^7.5.0"
},
"ci": {
"downstreamIgnoreList": [
Expand Down
Loading

0 comments on commit d660cab

Please sign in to comment.