Comparing version 2.0.3 to 2.0.4
@@ -259,3 +259,3 @@ 'use strict'; | ||
var id = docToProcess._id; | ||
docToProcess._id = { _id: id, _version: docToProcess._version }; | ||
docToProcess._id = { _id: id, _version: docToProcess._version || 1 }; | ||
docToProcess._version = (opName === 'remove') ? 'deleted:' + docToProcess._version : (docToProcess._version || 1); | ||
@@ -354,2 +354,2 @@ | ||
// export Mongoat object | ||
module.exports = Mongoat; | ||
module.exports = Mongoat; |
{ | ||
"name": "mongoat", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Mongoat is a MongoDb ODM", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,3 +22,2 @@ 'use strict'; | ||
_this.testCol.datetime(true); | ||
_this.testCol.version(true); | ||
}) | ||
@@ -35,3 +34,3 @@ .then(done); | ||
expect(mongObject.lastName).toBe('KHATAL'); | ||
expect(mongObject.age).toBe(25); | ||
expect(mongObject.age).toBe(26); | ||
expect(mongObject.company).toBe('Dial Once'); | ||
@@ -52,3 +51,3 @@ expect(mongObject.job).toBe('software engineer'); | ||
// test findAndModify without hooks | ||
it('should upsert new document to Person collection', function (done) { | ||
it('should upsert new document to Person collection [test with versionning disabled]', function (done) { | ||
_this.testCol.findAndModify( | ||
@@ -70,2 +69,3 @@ { firstName: 'Yacine' }, | ||
expect(mongObject.lastErrorObject.n).toBe(1); | ||
expect(mongObject.value._version).toBeUndefined(); | ||
done(); | ||
@@ -75,2 +75,26 @@ }); | ||
// test findAndModify without hooks | ||
it('should update new document to Person collection [test with versionning enabled]', function (done) { | ||
_this.testCol.version(true); | ||
_this.testCol.findAndModify( | ||
{ firstName: 'Yacine' }, | ||
[['_id', 1]], | ||
{ $set: { age: 26 } }, | ||
{ upsert: true, new: true }, | ||
function (err, mongObject) { | ||
expect(err).toBe(null); | ||
expect(typeof mongObject).toBe('object'); | ||
expect(typeof mongObject.value).toBe('object'); | ||
expect(typeof mongObject.lastErrorObject).toBe('object'); | ||
expect(mongObject.value.firstName).toBe('Yacine'); | ||
expect(mongObject.value.lastName).toBe('KHATAL'); | ||
expect(mongObject.value.age).toBe(26); | ||
expect(mongObject.ok).toBe(1); | ||
expect(mongObject.lastErrorObject.updatedExisting).toBe(true); | ||
expect(mongObject.lastErrorObject.n).toBe(1); | ||
expect(mongObject.value._version).toBe(2); | ||
done(); | ||
}); | ||
}); | ||
// test with multiple before and after findAndModify hooks | ||
@@ -99,3 +123,3 @@ it('should findAndModify document from Person collection and handle before and after update hooks', function (done) { | ||
expect(mongObject.value.company).toBe('Dial Once'); | ||
expect(mongObject.value.age).toBe(25); | ||
expect(mongObject.value.age).toBe(26); | ||
expect(mongObject.ok).toBe(1); | ||
@@ -115,3 +139,3 @@ expect(mongObject.lastErrorObject.updatedExisting).toBe(true); | ||
expect(mongObject.value.company).toBe('Dial Once'); | ||
expect(mongObject.value.age).toBe(25); | ||
expect(mongObject.value.age).toBe(26); | ||
expect(mongObject.ok).toBe(1); | ||
@@ -137,3 +161,3 @@ expect(mongObject.lastErrorObject.updatedExisting).toBe(true); | ||
expect(mongObject.value.company).toBe('Dial Once'); | ||
expect(mongObject.value.age).toBe(25); | ||
expect(mongObject.value.age).toBe(26); | ||
expect(mongObject.ok).toBe(1); | ||
@@ -140,0 +164,0 @@ expect(mongObject.lastErrorObject.updatedExisting).toBe(true); |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 14 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3639155
54
2436
1
14