🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

bourne

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bourne - npm Package Compare versions

Comparing version

to
0.3.0

19

lib/bourne.js

@@ -73,2 +73,13 @@ /*

};
Bourne.prototype.insertAll = function (records, callback) {
var ids = [];
records.forEach(function (record) {
record.id = this._id++;
ids.push(record.id);
this.data.push(record);
}.bind(this));
this.store.set(this.name, JSON.stringify(this.data), function () {
if (callback) this.find({ id: { $in: ids }}, callback);
}.bind(this));
};

@@ -84,2 +95,10 @@ var operators = {

return record[key] <= value;
},
$in: function (key, values, record) {
for (var i = 0; i < values.length; i++) {
if (record[key] === values[i]) {
return true;
}
}
return false;
}

@@ -86,0 +105,0 @@ };

2

package.json
{
"name": "bourne",
"description": "A simple serverless database stored in a JSON file.",
"version": "0.2.0",
"version": "0.3.0",
"homepage": "https://github.com/andreww8088/bourne",

@@ -6,0 +6,0 @@ "author": {

@@ -120,16 +120,2 @@ 'use strict';

},
'can register custom query operator': function (test) {
Bourne.operator('$in', function (key, values, record) {
for (var i = 0; i < values.length; i++) {
if (record[key] === values[i]) {
return true;
}
}
});
this.db.find({ firstname: { $in: [testRecord1.firstname, testRecord2.firstname] } }, function (err, records) {
test.equal(records.length, 2, 'should receive two records');
test.done();
});
},
'can find a single record': function (test) {

@@ -147,2 +133,9 @@ this.db.findOne({ firstname: testRecord1.firstname }, function (err, record) {

},
'can insert multiple records': function (test) {
var db = new Bourne(testName, { reset: true });
db.insertAll([testRecord1, testRecord2], function (err, records) {
test.equal(records.length, 2);
test.done();
});
},
'can updated records': function (test) {

@@ -149,0 +142,0 @@ this.db.update({ firstname: testRecord1.firstname }, { age: 200 }, function (err, records) {