New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

loopback-connector-mongodb

Package Overview
Dependencies
Maintainers
4
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-connector-mongodb - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

benchmarks/index.js

28

CHANGES.md

@@ -1,6 +0,32 @@

2015-02-21, Version 1.8.0
2015-05-28, Version 1.9.0
=========================
* Add options (Raymond Feng)
* Update README.md (Simon Ho)
* Add leak detection (Simon Ho)
* Add benchmarks (Simon Ho)
* Support `ctx.isNewInstance` (Miroslav Bajtoš)
* Update deps (Raymond Feng)
* Cleanup for returning count on update/delete (Simon Ho)
* Default to `undefined` instead of `0` (Simon Ho)
* Return info object with affected items count (Simon Ho)
* added doc about allowExtendedOperators (Pasindu De Silva)
* Make test instructions more meaningful (Simon Ho)
2015-02-20, Version 1.8.0
=========================
* Update deps (Raymond Feng)
* Re-enable the inclusion tests (Raymond Feng)

@@ -7,0 +33,0 @@

85

lib/mongodb.js

@@ -184,3 +184,3 @@ /*!

*/
MongoDB.prototype.create = function (model, data, callback) {
MongoDB.prototype.create = function (model, data, options, callback) {
var self = this;

@@ -230,3 +230,3 @@ if (self.debug) {

*/
MongoDB.prototype.save = function (model, data, callback) {
MongoDB.prototype.save = function (model, data, options, callback) {
var self = this;

@@ -251,3 +251,20 @@ if (self.debug) {

}
callback && callback(err, result && result.ops);
var info = {};
if (result && result.result) {
// create result formats:
// { ok: 1, n: 1, upserted: [ [Object] ] }
// { ok: 1, nModified: 0, n: 1, upserted: [ [Object] ] }
//
// update result formats:
// { ok: 1, n: 1 }
// { ok: 1, nModified: 1, n: 1 }
if (result.result.ok === 1 && result.result.n === 1) {
info.isNewInstance = !!result.result.upserted;
} else {
debug('save result format not recognized: %j', result.result);
}
}
callback && callback(err, result && result.ops, info);
});

@@ -263,3 +280,3 @@ };

*/
MongoDB.prototype.exists = function (model, id, callback) {
MongoDB.prototype.exists = function (model, id, options, callback) {
var self = this;

@@ -284,3 +301,3 @@ if (self.debug) {

*/
MongoDB.prototype.find = function find(model, id, callback) {
MongoDB.prototype.find = function find(model, id, options, callback) {
var self = this;

@@ -365,3 +382,3 @@ if (self.debug) {

*/
MongoDB.prototype.updateOrCreate = function updateOrCreate(model, data, callback) {
MongoDB.prototype.updateOrCreate = function updateOrCreate(model, data, options, callback) {
var self = this;

@@ -397,3 +414,11 @@ if (self.debug) {

}
callback && callback(err, object);
var info;
if (result && result.lastErrorObject) {
info = { isNewInstance: !result.lastErrorObject.updatedExisting };
} else {
debug('updateOrCreate result format not recognized: %j', result);
}
callback && callback(err, object, info);
});

@@ -408,3 +433,3 @@ };

*/
MongoDB.prototype.destroy = function destroy(model, id, callback) {
MongoDB.prototype.destroy = function destroy(model, id, options, callback) {
var self = this;

@@ -519,3 +544,3 @@ if (self.debug) {

*/
MongoDB.prototype.all = function all(model, filter, callback) {
MongoDB.prototype.all = function all(model, filter, options, callback) {
var self = this;

@@ -604,3 +629,3 @@ if (self.debug) {

if (filter && filter.include) {
self._models[model].model.include(objs, filter.include, callback);
self._models[model].model.include(objs, filter.include, options, callback);
} else {

@@ -618,3 +643,3 @@ callback(null, objs);

*/
MongoDB.prototype.destroyAll = function destroyAll(model, where, callback) {
MongoDB.prototype.destroyAll = function destroyAll(model, where, options, callback) {
var self = this;

@@ -629,8 +654,11 @@ if (self.debug) {

where = self.buildWhere(model, where);
this.collection(model).remove(where || {}, function (err, result) {
if (self.debug) {
debug('destroyAll.callback', model, where, err, result);
}
var count = result && result.result && result.result.n || 0;
callback && callback(err, count);
this.collection(model).remove(where || {}, function(err, info) {
if (err) return callback && callback(err);
if (self.debug)
debug('destroyAll.callback', model, where, err, info);
var affectedCount = info.result ? info.result.n : undefined;
callback && callback(err, {count: affectedCount});
});

@@ -647,3 +675,3 @@ };

*/
MongoDB.prototype.count = function count(model, callback, where) {
MongoDB.prototype.count = function count(model, where, options, callback) {
var self = this;

@@ -668,3 +696,3 @@ if (self.debug) {

*/
MongoDB.prototype.updateAttributes = function updateAttrs(model, id, data, cb) {
MongoDB.prototype.updateAttributes = function updateAttrs(model, id, data, options, cb) {
var self = this;

@@ -706,3 +734,3 @@

MongoDB.prototype.update =
MongoDB.prototype.updateAll = function updateAll(model, where, data, cb) {
MongoDB.prototype.updateAll = function updateAll(model, where, data, options, cb) {
var self = this;

@@ -721,8 +749,11 @@ if (self.debug) {

this.collection(model).update(where, data, {multi: true, upsert: false},
function (err, result) {
if (self.debug) {
debug('updateAll.callback', model, where, data, err, result);
}
var count = result && result.result && result.result.n || 0;
cb && cb(err, count);
function(err, info) {
if (err) return cb && cb(err);
if (self.debug)
debug('updateAll.callback', model, where, data, err, info);
var affectedCount = info.result ? info.result.n : undefined;
cb && cb(err, {count: affectedCount});
});

@@ -877,3 +908,3 @@ };

if(err) {
if(!(err.name === 'MongoError' && err.ok === 0
if(!(err.name === 'MongoError' && err.ok === 0
&& err.errmsg === 'ns not found')) {

@@ -880,0 +911,0 @@ // For errors other than 'ns not found' (collection doesn't exist)

{
"name": "loopback-connector-mongodb",
"version": "1.8.0",
"version": "1.9.0",
"description": "LoopBack MongoDB Connector",

@@ -14,2 +14,4 @@ "keywords": [

"scripts": {
"benchmarks": "make benchmarks",
"leak-detection": "make leak-detection",
"test": "make test"

@@ -24,8 +26,11 @@ },

"devDependencies": {
"benchmark": "^1.0.0",
"bluebird": "^2.9.12",
"loopback-datasource-juggler": "^2.15.0",
"memwatch": "^0.2.2",
"mocha": "^2.1.0",
"rc": "^0.6.0",
"rc": "^1.0.0",
"semver": "^4.2.0",
"should": "^5.0.0"
"should": "^5.0.0",
"sinon": "^1.14.1"
},

@@ -32,0 +37,0 @@ "repository": {

@@ -45,8 +45,45 @@ ## loopback-connector-mongodb

###Additional Settings
allowExtendedOperators - ```false``` by default, ```true``` allows to use mongo operators like
```$currentDate, $inc, $max, $min, $mul, $rename, $setOnInsert, $set, $unset, $addToSet,
$pop, $pullAll, $pull, $pushAll, $push, $bit ```.
## Running tests
npm test
The tests in this repository are mainly integration tests, meaning you will need
to run them using our preconfigured test server.
1. Ask a core developer for instructions on how to set up test server
credentials on your machine
2. `npm test`
## Running benchmarks
**Benchmarks must be run on a Unix-like operating system.**
```
make benchmarks
```
The results will be output in `./benchmarks/results.md`.
## Leak detection
Tests run for 100 iterations by default, but can be increased by setting the
env var `ITERATIONS`.
```
make leak-detection # run 100 iterations (default)
```
or
```
ITERATIONS=1000 make leak-detection # run 1000 iterations
```
## Release notes
* 1.1.7 - Do not return MongoDB-specific _id to client API, except if specifically specified in the model definition

@@ -436,3 +436,3 @@ // This test written in mocha+should.js

should.not.exist(err);
updatedusers.should.be.equal(2);
updatedusers.should.have.property('count', 2);

@@ -466,3 +466,3 @@ User.find({where:{age:31}},function(err2,foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(3);
updatedusers.should.have.property('count', 3);

@@ -479,3 +479,3 @@ User.find({where:{age:40}},function(err2, foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(3);
updatedusers.should.have.property('count', 3);

@@ -524,3 +524,3 @@ User.find({where:{age:40}},function(err2, foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);

@@ -552,3 +552,3 @@ User.find({where: {name: 'Alex'}}, function(err, founduser) {

should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);

@@ -576,7 +576,7 @@ User.find({where: {name: 'Ray'}}, function(err, foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);
User.updateAll({name: 'Simon'}, {'$min': {age: 31}}, function(err, updatedusers) {
should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);

@@ -604,3 +604,3 @@ User.find({where: {name: 'Simon'}}, function(err, foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);

@@ -627,3 +627,3 @@ User.find({where: {name: 'Al'}}, function(err, foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);

@@ -649,3 +649,3 @@ User.find({where: {firstname: 'Al'}}, function(err, foundusers) {

should.not.exist(err);
updatedusers.should.be.equal(1);
updatedusers.should.have.property('count', 1);

@@ -652,0 +652,0 @@ User.find({where: {name: 'Al'}}, function(err, foundusers) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc