@syntropy/mongoose-document-versioner
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "@syntropy/mongoose-document-versioner", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Force version to increment every time you update or save a mongoose document", | ||
@@ -5,0 +5,0 @@ "main": "src/", |
@@ -12,2 +12,3 @@ const set = require('lodash.set'); | ||
if ( | ||
!has(this, '_update.version') && | ||
!has(this, '_update.$inc.version') && | ||
@@ -14,0 +15,0 @@ !has(this, '_update.$set.version') && |
@@ -49,3 +49,3 @@ const assert = require('assert'); | ||
it('does not bump the version of a document in an updateOne query when the version is already set in the query', function () { | ||
it('correctly handles updateOne when the version is set in the query', function () { | ||
return Starship.create({name: 'USS Geronimo'}) | ||
@@ -64,2 +64,16 @@ .then(function (ship) { | ||
it('correctly handles findOneAndUpdate when the version is set in the query', function () { | ||
return Starship.create({name: 'USS Geronimo'}) | ||
.then(function (ship) { | ||
assert.equal(ship.version, 1); | ||
return Starship.findOneAndUpdate({name: 'USS Geronimo'}, {version: 3}, {new: true}) | ||
.then(function () { | ||
return Starship.findById(ship.id); | ||
}); | ||
}) | ||
.then(function (ship) { | ||
assert.equal(ship.version, 3); | ||
}); | ||
}); | ||
it('bumps the version of a document with an updateMany query', function () { | ||
@@ -66,0 +80,0 @@ return Promise.all([ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41961
179