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

p-odm

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-odm - npm Package Compare versions

Comparing version 3.1.7 to 3.1.8

63

lib/index.js

@@ -387,5 +387,8 @@ 'use strict';

options.safe = _safeOptions;
// always include oid
document._id = oid;
return txcollection.save(document, options, callback);
var txdocument = {
_id: oid,
fields: fields,
doc: document
};
return txcollection.save(txdocument, options, callback);
});

@@ -426,5 +429,53 @@ });

options.safe = _safeOptions;
// remove _id
delete document._id;
return collection.update({_id: oid}, {$set: document}, options, callback);
// was this snapshot a full doc or partial?
var fields = Object.keys(document.fields);
if (fields.length > 0) {
// partial
// remove _id
delete document.doc._id;
var update = {$set: document.doc};
// generate unset list
var docFields = Object.keys(document.doc);
var i, j;
for (i = 0; i < docFields.length; i++) {
for (j = 0; j < fields.length; j++) {
if (docFields[i] === fields[j]) {
fields.splice(j, 1);
break;
}
}
}
if (fields.length > 0) {
update.$unset = {};
for (j = 0; j < fields.length; j++) {
update.$unset[fields[j]] = 1;
}
}
collection.update({_id: oid}, update, options, function (err) {
if (err) {
return callback(err);
}
// clean up
delete options.safe;
return txcollection.remove({_id: oid}, options, callback);
});
} else {
// full
// ensure _id
document.doc._id = oid;
collection.save(document.doc, options, function (err) {
if (err) {
return callback(err);
}
// clean up
delete options.safe;
return txcollection.remove({_id: oid}, options, callback);
});
}
});

@@ -431,0 +482,0 @@ });

2

package.json

@@ -8,3 +8,3 @@ {

],
"version": "3.1.7",
"version": "3.1.8",
"engines": {

@@ -11,0 +11,0 @@ "node": ">=0.4.12"

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