Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

viewmodel

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewmodel - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

10

lib/databases/couchdb.js

@@ -327,8 +327,8 @@ 'use strict';

case 'delete':
this.db.get(vm.id, function(err, doc) {
if (doc) {
self.db.remove(doc._id, doc._rev, callback);
} else {
callback(null);
var obj = vm.toJSON();
this.db.remove(obj._id, obj._rev, function(err) {
if (err && err.error === 'conflict' && err.reason.indexOf('update conflict') >= 0) {
return callback(new ConcurrencyError());
}
callback(err, vm);
});

@@ -335,0 +335,0 @@ break;

@@ -371,6 +371,7 @@ 'use strict';

refresh: true,
version: vm.get('_version'),
id: vm.id
}, function (err, res) {
if (err && err.message.toLowerCase().indexOf('not found') >= 0) {
err = null;
if (err && (err.message.toLowerCase().indexOf('version') >= 0 || err.message.toLowerCase().indexOf('not found') >= 0)) {
return callback(new ConcurrencyError());
}

@@ -377,0 +378,0 @@ if (callback) callback(err);

@@ -112,2 +112,5 @@ 'use strict';

case 'delete':
if (col[vm.id] && vm.has('_hash') && col[vm.id]._hash && vm.get('_hash') !== col[vm.id]._hash) {
return callback(new ConcurrencyError());
}
delete col[vm.id];

@@ -114,0 +117,0 @@ return callback(null, vm);

@@ -187,3 +187,21 @@ 'use strict';

case 'delete':
this.collection.remove({ _id: vm.id }, { safe: true }, callback);
var currentHash = vm.get('_hash');
obj = vm.toJSON();
obj._id = obj.id;
var query = { _id: obj._id };
if (currentHash) {
query._hash = currentHash;
}
this.collection.remove(query, { safe: true }, function(err, modifiedCount) {
if (isNew) {
if (modifiedCount && modifiedCount.result && modifiedCount.result.n === 0) {
return callback(new ConcurrencyError());
}
} else {
if (modifiedCount === 0) {
return callback(new ConcurrencyError());
}
}
callback(err, vm);
});
break;

@@ -190,0 +208,0 @@ case 'create':

@@ -326,3 +326,34 @@ 'use strict';

case 'delete':
this.client.del(prefixedId, callback);
this.client.watch(prefixedId, function (err) {
if (err) {
return callback(err);
}
self.get(vm.id, function (err, savedVm) {
if (err) {
return callback(err);
}
var currentHash = savedVm.get('_hash');
if (currentHash && vm.has('_hash') && vm.get('_hash') != currentHash) {
self.client.unwatch(function (err) {
err = new ConcurrencyError();
if (callback) {
callback(err);
}
});
return;
}
self.client.multi([['del', prefixedId]]).exec(function (err, replies) {
if (err) {
return callback(err);
}
if (!replies || replies.length === 0 || replies[0] !== 'OK') {
return callback(new ConcurrencyError());
}
vm.actionOnCommit = 'update';
callback(err, vm);
});
});
});
break;

@@ -329,0 +360,0 @@ case 'create':

@@ -143,3 +143,15 @@ 'use strict';

case 'delete':
this.collection.remove({ _id: vm.id }, { safe: true }, callback);
var currentHash = vm.get('_hash');
obj = vm.toJSON();
obj._id = obj.id;
var query = { _id: obj._id };
if (currentHash) {
query._hash = currentHash;
}
this.collection.remove(query, { safe: true }, function(err, modifiedCount) {
if (modifiedCount === 0) {
return callback(new ConcurrencyError());
}
callback(err, vm);
});
break;

@@ -146,0 +158,0 @@ case 'create':

{
"author": "adrai",
"name": "viewmodel",
"version": "1.4.2",
"version": "1.5.0",
"private": false,

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -0,1 +1,4 @@

## [v1.5.0](https://github.com/adrai/node-viewmodel/compare/v1.4.2...v1.5.0)
- catch concurrency error on destroy commit
## [v1.4.2](https://github.com/adrai/node-viewmodel/compare/v1.3.4...v1.4.2)

@@ -2,0 +5,0 @@ - added elasticsearch support

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