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

nedb

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nedb - npm Package Compare versions

Comparing version 0.8.6 to 0.8.7

42

lib/datastore.js

@@ -161,2 +161,3 @@ var customUtils = require('./customUtils')

* Update one or several documents in all indexes
* To update multiple documents, oldDoc must be an array of { oldDoc, newDoc } pairs
* If one update violates a constraint, all changes are rolled back

@@ -179,3 +180,3 @@ */

// If an error happened, we need to rollback the insert on all other indexes
// If an error happened, we need to rollback the update on all other indexes
if (error) {

@@ -385,4 +386,2 @@ for (i = 0; i < failingIndex; i += 1) {

, multi, upsert
, updatedDocs = []
, candidates
, i

@@ -415,6 +414,9 @@ ;

, function () { // Perform the update
var modifiedDoc;
var modifiedDoc
, candidates = self.getCandidates(query)
, modifications = []
;
candidates = self.getCandidates(query);
// Preparing update (if an error is thrown here neither the datafile nor
// the in-memory indexes are affected)
try {

@@ -425,4 +427,3 @@ for (i = 0; i < candidates.length; i += 1) {

modifiedDoc = model.modify(candidates[i], updateQuery);
self.updateIndexes(candidates[i], modifiedDoc);
updatedDocs.push(modifiedDoc);
modifications.push({ oldDoc: candidates[i], newDoc: modifiedDoc });
}

@@ -433,4 +434,12 @@ }

}
// Change the docs in memory
try {
self.updateIndexes(modifications);
} catch (err) {
return callback(err);
}
self.persistence.persistNewState(updatedDocs, function (err) {
// Update the datafile
self.persistence.persistNewState(_.pluck(modifications, 'newDoc'), function (err) {
if (err) { return callback(err); }

@@ -489,4 +498,17 @@ return callback(null, numReplaced);

/*
var db = new Datastore({ inMemoryOnly: true })
//db.ensureIndex({ fieldName: 'tag' });
module.exports = Datastore;
db.insert({ tag: ['a', 'b', 'c'] }, function () {
db.find({ tag: 'b' }, function (err, item) {
console.log(err);
console.log(item);
});
});
*/
module.exports = Datastore;

@@ -65,3 +65,5 @@ var BinarySearchTree = require('binary-search-tree').AVLTree

* Insert an array of documents in the index
* If a constraint is violated, an error should be thrown and the changes rolled back
* If a constraint is violated, the changes should be rolled back and an error thrown
*
* @API private
*/

@@ -134,2 +136,4 @@ Index.prototype.insertMultipleDocs = function (docs) {

* @param {Array of oldDoc, newDoc pairs} pairs
*
* @API private
*/

@@ -136,0 +140,0 @@ Index.prototype.updateMultipleDocs = function (pairs) {

@@ -163,3 +163,3 @@ /**

* We need to compare with undefined as it will be used in indexes
* In the case of objects and arrays, we compare the serialized versions
* In the case of objects and arrays, we deep-compare
* If two objects dont have the same type, the (arbitrary) type hierarchy is: undefined, null, number, strings, boolean, dates, arrays, objects

@@ -166,0 +166,0 @@ * Return -1 if a < b, 1 if a > b and 0 if a = b (note that equality here is NOT the same as defined in areThingsEqual!)

{
"name": "nedb",
"version": "0.8.6",
"version": "0.8.7",
"author": {

@@ -5,0 +5,0 @@ "name": "tldr.io",

Sorry, the diff of this file is too big to display

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