Socket
Socket
Sign inDemoInstall

marsdb

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marsdb - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

browser_polyfills.js

46

dist/Cursor.js

@@ -21,2 +21,6 @@ 'use strict';

var _lodashCollectionEach = require('lodash/collection/each');
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _eventemitter3 = require('eventemitter3');

@@ -34,5 +38,5 @@

var _ObjectRetriver = require('./ObjectRetriver');
var _DocumentRetriver = require('./DocumentRetriver');
var _ObjectRetriver2 = _interopRequireDefault(_ObjectRetriver);
var _DocumentRetriver2 = _interopRequireDefault(_DocumentRetriver);

@@ -252,36 +256,15 @@ var _DocumentMatcher = require('./DocumentMatcher');

return new _ObjectRetriver2['default'](this.db).retriveForQeury(this._query).then(function (docs) {
return new _DocumentRetriver2['default'](this.db).retriveForQeury(this._query).then(function (docs) {
var results = [];
var withFastLimit = _this4._limit && !_this4._skip && !_this4._sorter;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = docs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var d = _step.value;
var match = _this4._matcher.documentMatches(d);
if (match.result) {
results.push(d);
}
if (withFastLimit && results.length === _this4._limit) {
break;
}
(0, _lodashCollectionEach2['default'])(docs, function (d) {
var match = _this4._matcher.documentMatches(d);
if (match.result) {
results.push(d);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
if (withFastLimit && results.length === _this4._limit) {
return false;
}
}
});

@@ -325,3 +308,2 @@ if (withFastLimit) {

exports.Cursor = Cursor;
exports['default'] = Cursor;

@@ -111,2 +111,6 @@ 'use strict';

}
// TODO improve performance, we should be smarter
// and don't emit fully request update in many
// cases
}, {

@@ -113,0 +117,0 @@ key: 'maybeUpdate',

@@ -17,2 +17,6 @@ 'use strict';

var _lodashObjectAssign = require('lodash/object/assign');
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _lodashLangIsArray = require('lodash/lang/isArray');

@@ -98,3 +102,3 @@

// Move given raw object to a Document
Object.assign(this, raw);
(0, _lodashObjectAssign2['default'])(this, raw);
}

@@ -101,0 +105,0 @@

@@ -37,5 +37,5 @@ 'use strict';

var _ObjectRetriver = require('./ObjectRetriver');
var _DocumentRetriver = require('./DocumentRetriver');
var _ObjectRetriver2 = _interopRequireDefault(_ObjectRetriver);
var _DocumentRetriver2 = _interopRequireDefault(_DocumentRetriver);

@@ -88,35 +88,14 @@ var _DocumentMatcher = require('./DocumentMatcher');

return new _ObjectRetriver2['default'](this.db).retriveForQeury(this._query).then(function (docs) {
return new _DocumentRetriver2['default'](this.db).retriveForQeury(this._query).then(function (docs) {
var oldResults = [];
var newResults = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = docs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var d = _step.value;
var match = _this._matcher.documentMatches(d);
if (match.result) {
var matchOpts = (0, _lodashObjectAssign2['default'])({ arrayIndices: match.arrayIndices }, options);
var newDoc = _this._modifyDocument(d, mod, matchOpts);
newResults.push(newDoc);
oldResults.push(d);
}
(0, _lodashCollectionEach2['default'])(docs, function (d) {
var match = _this._matcher.documentMatches(d);
if (match.result) {
var matchOpts = (0, _lodashObjectAssign2['default'])({ arrayIndices: match.arrayIndices }, options);
var newDoc = _this._modifyDocument(d, mod, matchOpts);
newResults.push(newDoc);
oldResults.push(d);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
});

@@ -123,0 +102,0 @@ return {

@@ -42,2 +42,6 @@ /**

var _lodashCollectionEach = require('lodash/collection/each');
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
// Internal utils

@@ -272,2 +276,4 @@ function isInfOrNan(val) {

value: function clone(v) {
var _this2 = this;
var ret;

@@ -313,27 +319,5 @@ if (typeof v !== 'object') {

ret = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _lodashObjectKeys2['default'])(v)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
ret[key] = this.clone(v[key]);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
(0, _lodashCollectionEach2['default'])(v, function (val, key) {
ret[key] = _this2.clone(val);
});
return ret;

@@ -349,3 +333,3 @@ }

value: function _setupBuiltinConverters() {
var _this2 = this;
var _this3 = this;

@@ -406,3 +390,3 @@ this._builtinConverters = [{ // Date

}
return _this2._builtinConverters.some(function (converter) {
return _this3._builtinConverters.some(function (converter) {
return converter.matchJSONValue(obj);

@@ -413,27 +397,5 @@ });

var newObj = {};
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = (0, _lodashObjectKeys2['default'])(obj)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var key = _step2.value;
newObj[key] = _this2.toJSONValue(obj[key]);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2['return']) {
_iterator2['return']();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
(0, _lodashCollectionEach2['default'])(obj, function (val, key) {
newObj[key] = _this3.toJSONValue(val);
});
return { $escape: newObj };

@@ -443,27 +405,5 @@ },

var newObj = {};
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = (0, _lodashObjectKeys2['default'])(obj.$escape)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var key = _step3.value;
newObj[key] = _this2.fromJSONValue(obj.$escape[key]);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3['return']) {
_iterator3['return']();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
(0, _lodashCollectionEach2['default'])(obj.$escape, function (val, key) {
newObj[key] = _this3.fromJSONValue(val);
});
return newObj;

@@ -476,3 +416,3 @@ }

matchObject: function (obj) {
return _this2._isCustomType(obj);
return _this3._isCustomType(obj);
},

@@ -485,6 +425,6 @@ toJSONValue: function (obj) {

var typeName = obj.$type;
if (!(0, _lodashObjectHas2['default'])(_this2._customTypes, typeName)) {
if (!(0, _lodashObjectHas2['default'])(_this3._customTypes, typeName)) {
throw new Error('Custom EJSON type ' + typeName + ' is not defined');
}
var converter = _this2._customTypes[typeName];
var converter = _this3._customTypes[typeName];
return converter(obj.$value);

@@ -506,2 +446,4 @@ }

value: function _adjustTypesToJSONValue(obj) {
var _this4 = this;
// Is it an atom that we need to adjust?

@@ -522,39 +464,16 @@ if (obj === null) {

// Iterate over array or object structure.
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
(0, _lodashCollectionEach2['default'])(obj, function (value, key) {
if (typeof value !== 'object' && value !== undefined && !isInfOrNan(value)) {
return;
}
try {
for (var _iterator4 = (0, _lodashObjectKeys2['default'])(obj)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var key = _step4.value;
var value = obj[key];
if (typeof value !== 'object' && value !== undefined && !isInfOrNan(value)) {
continue;
}
var changed = this._toJSONValueHelper(value);
if (changed) {
obj[key] = changed;
continue;
}
// if we get here, value is an object but not adjustable
// at this level. recurse.
this._adjustTypesToJSONValue(value);
var changed = _this4._toJSONValueHelper(value);
if (changed) {
obj[key] = changed;
return;
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4['return']) {
_iterator4['return']();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
// if we get here, value is an object but not adjustable
// at this level. recurse.
_this4._adjustTypesToJSONValue(value);
});
return obj;

@@ -587,2 +506,4 @@ }

value: function _adjustTypesFromJSONValue(obj) {
var _this5 = this;
if (obj === null) {

@@ -601,37 +522,14 @@ return null;

var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = (0, _lodashObjectKeys2['default'])(obj)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var key = _step5.value;
var value = obj[key];
if (typeof value === 'object') {
var changed = this._fromJSONValueHelper(value);
if (value !== changed) {
obj[key] = changed;
continue;
}
// if we get here, value is an object but not adjustable
// at this level. recurse.
this._adjustTypesFromJSONValue(value);
(0, _lodashCollectionEach2['default'])(obj, function (value, key) {
if (typeof value === 'object') {
var changed = _this5._fromJSONValueHelper(value);
if (value !== changed) {
obj[key] = changed;
return;
}
// if we get here, value is an object but not adjustable
// at this level. recurse.
_this5._adjustTypesFromJSONValue(value);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5['return']) {
_iterator5['return']();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
});
return obj;

@@ -638,0 +536,0 @@ }

@@ -24,2 +24,10 @@ 'use strict';

var _lodashObjectKeys = require('lodash/object/keys');
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _lodashCollectionEach = require('lodash/collection/each');
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _invariant = require('invariant');

@@ -62,36 +70,15 @@

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = sets[0][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var v = _step.value;
var isResValue = true;
for (var i = 1; i < sets.length; i++) {
isResValue = sets[i].has(v);
isResValue = include ? isResValue : !isResValue;
if (!isResValue) {
break;
}
(0, _lodashCollectionEach2['default'])(sets[0], function (v) {
var isResValue = true;
for (var i = 1; i < sets.length; i++) {
isResValue = sets[i].has(v);
isResValue = include ? isResValue : !isResValue;
if (!isResValue) {
return false;
}
if (isResValue) {
result.add(v);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
if (isResValue) {
result.add(v);
}
}
});

@@ -260,3 +247,3 @@ return Array.from(result);

var sortKeys = Object.keys(this.sortObj);
var sortKeys = (0, _lodashObjectKeys2['default'])(this.sortObj);

@@ -303,3 +290,3 @@ if (sortKeys.length > 1) {

query = _normilizeQuery(query);
var queryKeys = Object.keys(query);
var queryKeys = (0, _lodashObjectKeys2['default'])(query);
var unusedKeys = queryKeys.filter(function (x) {

@@ -395,3 +382,3 @@ return !_this3._usedKeys.has(x);

var basic = _makeMatchResult();
var keys = Object.keys(query);
var keys = (0, _lodashObjectKeys2['default'])(query);
var dollarFirstKeys = keys.filter(function (k) {

@@ -409,29 +396,8 @@ return k && k[0] === '$';

if (isOnlyDollar && dollarFirstKeys.length) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = dollarFirstKeys[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var key = _step2.value;
(0, _invariant2['default'])(QUERY_COMP_OPS_IMPL[key], 'execCompareQuery(...): operation %s not supported', key);
if (query[key] !== undefined) {
QUERY_COMP_OPS_IMPL[key](index, query[key], basic, query);
}
(0, _lodashCollectionEach2['default'])(dollarFirstKeys, function (key) {
(0, _invariant2['default'])(QUERY_COMP_OPS_IMPL[key], 'execCompareQuery(...): operation %s not supported', key);
if (query[key] !== undefined) {
QUERY_COMP_OPS_IMPL[key](index, query[key], basic, query);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2['return']) {
_iterator2['return']();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
});
} else {

@@ -438,0 +404,0 @@ _makeMatchResult({ include: index.getMatching(query) }, basic);

@@ -73,3 +73,3 @@ 'use strict';

exports.Index = Index;
exports['default'] = Index;
exports['default'] = Index;
module.exports = exports['default'];

@@ -13,2 +13,6 @@ 'use strict';

var _lodashObjectKeys = require('lodash/object/keys');
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _invariant = require('invariant');

@@ -18,4 +22,2 @@

var _async = require('async');
var _Index = require('./Index');

@@ -25,2 +27,10 @@

var _DocumentRetriver = require('./DocumentRetriver');
var _DocumentRetriver2 = _interopRequireDefault(_DocumentRetriver);
var _PromiseQueue = require('./PromiseQueue');
var _PromiseQueue2 = _interopRequireDefault(_PromiseQueue);
/**

@@ -35,3 +45,3 @@ * Manager for controlling a list of indexes

function IndexManager(db) {
var concurrency = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -42,3 +52,5 @@ _classCallCheck(this, IndexManager);

this.indexes = {};
this.operationQueue = new _async.priorityQueue(this._indexOperationWorker.bind(this), concurrency);
this._queue = new _PromiseQueue2['default']({
concurrency: options.concurrency || 2
});

@@ -101,3 +113,3 @@ // By default ensure index by _id field

};
var buildPromise = this._queueOperation(this._doBuildIndex.bind(this, key), 10).then(cleanup, cleanup);
var buildPromise = this._queue.push(this._doBuildIndex.bind(this, key), 10).then(cleanup, cleanup);

@@ -119,3 +131,3 @@ this.indexes[key].buildPromise = buildPromise;

return Promise.all(Object.keys(this.indexes).map(function (k) {
return Promise.all((0, _lodashObjectKeys2['default'])(this.indexes).map(function (k) {
return _this2.ensureIndex({

@@ -138,3 +150,3 @@ fieldName: k,

return this._queueOperation(function (resolve, reject) {
return this._queue.push(function (resolve, reject) {
delete _this3.indexes[key];

@@ -155,4 +167,4 @@ resolve();

return this._queueOperation(function (resolve, reject) {
var keys = Object.keys(_this4.indexes);
return this._queue.push(function (resolve, reject) {
var keys = (0, _lodashObjectKeys2['default'])(_this4.indexes);
var failingIndex = null;

@@ -186,4 +198,4 @@ try {

return this._queueOperation(function (resolve, reject) {
var keys = Object.keys(_this5.indexes);
return this._queue.push(function (resolve, reject) {
var keys = (0, _lodashObjectKeys2['default'])(_this5.indexes);
var failingIndex = null;

@@ -215,4 +227,4 @@ try {

return this._queueOperation(function (resolve, reject) {
var keys = Object.keys(_this6.indexes);
return this._queue.push(function (resolve, reject) {
var keys = (0, _lodashObjectKeys2['default'])(_this6.indexes);
keys.forEach(function (k) {

@@ -233,4 +245,2 @@ _this6.indexes[k].remove(doc);

value: function _doBuildIndex(key, resolve, reject) {
var _this7 = this;
// Get and reset index

@@ -240,10 +250,6 @@ var index = this.indexes[key];

// Loop through all doucments in the store
// TODO improve performance:
// * deserialize cache
// * store LRU cache
// Loop through all doucments in the storage
var errors = [];
this.db.storage.loaded().then(function () {
_this7.db.storage.createReadStream().on('data', function (data) {
var doc = _this7.db.create(data.value);
new _DocumentRetriver2['default'](this.db).retriveAll().then(function (docs) {
docs.forEach(function (doc) {
try {

@@ -254,52 +260,11 @@ index.insert(doc);

}
}).on('end', function () {
if (errors.length) {
resolve();
} else {
reject(errors);
}
});
});
}
/**
* Adds given task (index operation) to the queue and
* wrap it with promise.
* Returned promise would be resolved/rejected only when
* given task complete
* @param {Function} task
* @return {Promise}
*/
}, {
key: '_queueOperation',
value: function _queueOperation(task) {
var _this8 = this;
var priority = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
return new Promise(function (resolve, reject) {
_this8.operationQueue.push(function () {
return new Promise(task);
}, priority, function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
if (errors.length) {
resolve();
} else {
reject(errors);
}
});
}
/**
* Worker for execitung queued tasks
* and moving to the next task when operation
* is ready.
* @param {Object} task
* @param {Object} next
*/
}, {
key: '_indexOperationWorker',
value: function _indexOperationWorker(task, next) {
task().then(next, next);
}
}]);

@@ -310,3 +275,3 @@

exports.IndexManager = IndexManager;
exports['default'] = IndexManager;
exports['default'] = IndexManager;
module.exports = exports['default'];

@@ -13,2 +13,10 @@ 'use strict';

var _lodashObjectKeys = require('lodash/object/keys');
var _lodashObjectKeys2 = _interopRequireDefault(_lodashObjectKeys);
var _PromiseQueue = require('./PromiseQueue');
var _PromiseQueue2 = _interopRequireDefault(_PromiseQueue);
var _eventemitter3 = require('eventemitter3');

@@ -26,6 +34,9 @@

var StorageManager = (function () {
function StorageManager(options) {
function StorageManager(db, options) {
_classCallCheck(this, StorageManager);
this.db = db;
this._queue = new _PromiseQueue2['default']();
this._storage = {};
this.reload();
}

@@ -36,16 +47,33 @@

value: function loaded() {
return Promise.resolve();
return this._loadedPromise;
}
}, {
key: 'reload',
value: function reload() {
var _this = this;
if (this._loadedPromise) {
this._loadedPromise = this._loadedPromise.then(function () {
return _this._loadStorage();
});
} else {
this._loadedPromise = this._loadStorage();
}
}
}, {
key: 'destroy',
value: function destroy() {
var _this2 = this;
return this._loadedPromise.then(function () {
_this2._storage = {};
});
}
}, {
key: 'persist',
value: function persist(key, value) {
var _this = this;
var _this3 = this;
return new Promise(function (resolve, reject) {
try {
_this._storage[key] = value;
resolve();
} catch (e) {
reject(e);
}
return this._loadedPromise.then(function () {
_this3._storage[key] = value;
});

@@ -56,11 +84,6 @@ }

value: function _delete(key) {
var _this2 = this;
var _this4 = this;
return new Promise(function (resolve, reject) {
try {
delete _this2._storage[key];
resolve();
} catch (e) {
reject(e);
}
return this._loadedPromise.then(function () {
delete _this4._storage[key];
});

@@ -71,10 +94,6 @@ }

value: function get(key) {
var _this3 = this;
var _this5 = this;
return new Promise(function (resolve, reject) {
try {
resolve(_this3._storage[key]);
} catch (e) {
reject(e);
}
return this._loadedPromise.then(function () {
return _this5._storage[key];
});

@@ -85,13 +104,20 @@ }

value: function createReadStream() {
var _this4 = this;
var _this6 = this;
var emitter = new _eventemitter32['default']();
process.nextTick(function () {
Object.keys(_this4._storage).forEach(function (k) {
emitter.emit('data', { value: _this4._storage[k] });
_this6._loadedPromise.then(function () {
(0, _lodashObjectKeys2['default'])(_this6._storage).forEach(function (k) {
emitter.emit('data', { value: _this6._storage[k] });
});
emitter.emit('end');
});
emitter.emit('end');
});
return emitter;
}
}, {
key: '_loadStorage',
value: function _loadStorage() {
return Promise.resolve();
}
}]);

@@ -102,3 +128,3 @@

exports.StorageManager = StorageManager;
exports['default'] = StorageManager;
exports['default'] = StorageManager;
module.exports = exports['default'];
'use strict';
module.exports = {
'src': 'lib/**/*',
'dist': 'dist',
src: 'lib/**/*',
dist: 'dist',
build: 'build',
browser: {
bundleName: 'marsdb.js',
bundleMinName: 'marsdb.min.js',
bundlePolyName: 'marsdb.polyfills.js',
entry: 'lib/Collection',
entryTests: 'browser_tests.js',
}
};

@@ -6,5 +6,21 @@ 'use strict';

var config = require('../config');
var gulpif = require('gulp-if');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var babelify = require('babelify');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var path = require('path');
gulp.task('build', ['lint'], function() {
gulp.task('build', [
'build:browser',
'build:browser:min',
'build:browser:tests',
'build:browser:polyfills',
'build:node'
]);
gulp.task('build:node', function() {
return gulp.src(config.src)

@@ -22,2 +38,101 @@ .pipe(babel({

.pipe(gulp.dest(config.dist));
});
});
gulp.task('build:browser:min', ['build:browser'], function() {
return gulp.src(path.join(config.build, config.browser.bundleName))
.pipe(rename(config.browser.bundleMinName))
.pipe(uglify())
.pipe(gulp.dest(config.build))
});
gulp.task('build:browser:polyfills', function() {
var customOpts = {
entries: './browser_polyfills.js',
debug: false,
fullPaths: false,
delay: 50
};
return browserify(customOpts).bundle()
.pipe(source(config.browser.bundlePolyName))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(config.build))
});
gulp.task('build:browser:tests', function() {
// Basic options
var customOpts = {
entries: './browser_tests.js',
debug: false,
fullPaths: false,
delay: 50
};
var b = browserify(customOpts);
// Transformations
var transforms = [
babelify.configure({
comments: true,
compact: false,
blacklist: [
'spec.functionName',
],
optional: [
'es7.trailingFunctionCommas',
]
}),
'brfs',
'bulkify',
'envify'
];
transforms.forEach(function(transform) {
b.transform(transform);
});
// Add handlers
return b.bundle()
.pipe(source('browser_tests.js'))
.pipe(buffer())
.pipe(gulp.dest(config.build))
});
gulp.task('build:browser', function() {
// Basic options
var customOpts = {
entries: './lib/Collection',
debug: false,
fullPaths: false,
delay: 50,
standalone: 'Mars.Collection'
};
var b = browserify(customOpts);
// Transformations
var transforms = [
babelify.configure({
comments: true,
compact: false,
blacklist: [
'spec.functionName',
],
optional: [
'es7.trailingFunctionCommas',
]
}),
'brfs',
'bulkify',
'envify'
];
transforms.forEach(function(transform) {
b.transform(transform);
});
// Add handlers
return b.bundle()
.pipe(source(config.browser.bundleName))
.pipe(buffer())
.pipe(gulp.dest(config.build))
});

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

gulp.task('clean', function(cb) {
del([config.dist]).then(function (paths) {
del([config.dist, config.build]).then(function (paths) {
cb();
});
});

@@ -10,3 +10,3 @@ 'use strict';

process.env.NODE_ENV = 'production';
runSequence('build', cb);
runSequence('build', 'lint', cb);
});

@@ -1,3 +0,3 @@

var Model = require('./dist/Model');
var Collection = require('./dist/Collection');
module.exports = Model;
module.exports = Collection;

@@ -0,5 +1,6 @@

import _each from 'lodash/collection/each';
import EventEmitter from 'eventemitter3';
import invariant from 'invariant';
import keyMirror from 'keymirror';
import ObjectRetriver from './ObjectRetriver';
import DocumentRetriver from './DocumentRetriver';
import DocumentMatcher from './DocumentMatcher';

@@ -45,3 +46,3 @@ import DocumentSorter from './DocumentSorter';

*/
export class Cursor extends EventEmitter {
export default class Cursor extends EventEmitter {
constructor(db, query) {

@@ -215,3 +216,3 @@ super();

_matchObjects() {
return new ObjectRetriver(this.db)
return new DocumentRetriver(this.db)
.retriveForQeury(this._query)

@@ -222,3 +223,3 @@ .then((docs) => {

for (const d of docs) {
_each(docs, (d) => {
const match = this._matcher.documentMatches(d);

@@ -229,5 +230,5 @@ if (match.result) {

if (withFastLimit && results.length === this._limit) {
break;
return false;
}
}
});

@@ -265,3 +266,1 @@ if (withFastLimit) {

}
export default Cursor;

@@ -64,2 +64,5 @@ import Cursor from './Cursor';

// TODO improve performance, we should be smarter
// and don't emit fully request update in many
// cases
maybeUpdate(newDoc, oldDoc) {

@@ -66,0 +69,0 @@ const removedFromResult = (

@@ -0,1 +1,2 @@

import _assign from 'lodash/object/assign';
import _isArray from 'lodash/lang/isArray';

@@ -47,5 +48,3 @@ import _isString from 'lodash/lang/isString';

Object.defineProperty(this, 'copy', {
value: () => {
return new Document(db, EJSON.clone(this));
},
value: () => new Document(db, EJSON.clone(this)),
writable: false,

@@ -55,5 +54,3 @@ });

Object.defineProperty(this, 'serialize', {
value: () => {
return EJSON.stringify(this);
},
value: () => EJSON.stringify(this),
writable: false,

@@ -71,3 +68,3 @@ });

// Move given raw object to a Document
Object.assign(this, raw);
_assign(this, raw);
}

@@ -74,0 +71,0 @@

@@ -7,3 +7,3 @@ import _isObject from 'lodash/lang/isObject';

import EJSON from './EJSON';
import ObjectRetriver from './ObjectRetriver';
import DocumentRetriver from './DocumentRetriver';
import DocumentMatcher from './DocumentMatcher';

@@ -23,3 +23,3 @@ import DocumentSorter from './DocumentSorter';

modify(mod, options = {}) {
return new ObjectRetriver(this.db)
return new DocumentRetriver(this.db)
.retriveForQeury(this._query)

@@ -29,3 +29,3 @@ .then((docs) => {

const newResults = [];
for (const d of docs) {
_each(docs, (d) => {
const match = this._matcher.documentMatches(d);

@@ -41,3 +41,4 @@ if (match.result) {

}
}
});
return {

@@ -44,0 +45,0 @@ updated: newResults,

@@ -12,2 +12,3 @@ /**

import _keys from 'lodash/object/keys';
import _each from 'lodash/collection/each';

@@ -261,5 +262,5 @@

ret = {};
for (var key of _keys(v)) {
ret[key] = this.clone(v[key]);
}
_each(v, (val, key) => {
ret[key] = this.clone(val);
});
return ret;

@@ -342,5 +343,5 @@ }

var newObj = {};
for (var key of _keys(obj)) {
newObj[key] = this.toJSONValue(obj[key]);
}
_each(obj, (val, key) => {
newObj[key] = this.toJSONValue(val);
});
return {$escape: newObj};

@@ -350,5 +351,5 @@ },

var newObj = {};
for (var key of _keys(obj.$escape)) {
newObj[key] = this.fromJSONValue(obj.$escape[key]);
}
_each(obj.$escape, (val, key) => {
newObj[key] = this.fromJSONValue(val);
});
return newObj;

@@ -408,7 +409,6 @@ },

// Iterate over array or object structure.
for (var key of _keys(obj)) {
var value = obj[key];
_each(obj, (value, key) => {
if (typeof value !== 'object' && value !== undefined &&
!isInfOrNan(value)) {
continue;
return;
}

@@ -419,3 +419,3 @@

obj[key] = changed;
continue;
return;
}

@@ -425,3 +425,3 @@ // if we get here, value is an object but not adjustable

this._adjustTypesToJSONValue(value);
}
});
return obj;

@@ -463,4 +463,3 @@ }

for (var key of _keys(obj)) {
var value = obj[key];
_each(obj, (value, key) => {
if (typeof value === 'object') {

@@ -470,3 +469,3 @@ var changed = this._fromJSONValueHelper(value);

obj[key] = changed;
continue;
return;
}

@@ -477,3 +476,3 @@ // if we get here, value is an object but not adjustable

}
}
});
return obj;

@@ -480,0 +479,0 @@ }

@@ -0,1 +1,3 @@

import _keys from 'lodash/object/keys';
import _each from 'lodash/collection/each';
import invariant from 'invariant';

@@ -19,3 +21,3 @@ import {QUERY_OPS} from './Document';

for (const v of sets[0]) {
_each(sets[0], (v) => {
let isResValue = true;

@@ -26,3 +28,3 @@ for (let i = 1; i < sets.length; i++) {

if (!isResValue) {
break;
return false;
}

@@ -33,3 +35,3 @@ }

}
}
});

@@ -206,3 +208,3 @@ return Array.from(result);

execSortQuery() {
const sortKeys = Object.keys(this.sortObj);
const sortKeys = _keys(this.sortObj);

@@ -241,3 +243,3 @@ if (sortKeys.length > 1) {

query = _normilizeQuery(query);
const queryKeys = Object.keys(query);
const queryKeys = _keys(query);
const unusedKeys = queryKeys.filter(x => !this._usedKeys.has(x));

@@ -321,3 +323,3 @@ const matchPromises = unusedKeys.map(

const basic = _makeMatchResult();
const keys = Object.keys(query);
const keys = _keys(query);
const dollarFirstKeys = keys.filter(k => k && k[0] === '$');

@@ -334,3 +336,3 @@ const pathKeys = keys.filter(k => k && k[0] !== '$');

if (isOnlyDollar && dollarFirstKeys.length) {
for (const key of dollarFirstKeys) {
_each(dollarFirstKeys, (key) => {
invariant(

@@ -344,3 +346,3 @@ QUERY_COMP_OPS_IMPL[key],

}
}
});
} else {

@@ -347,0 +349,0 @@ _makeMatchResult({include: index.getMatching(query)}, basic);

import invariant from 'invariant';
export class Index {
export default class Index {
constructor(options = {}) {

@@ -50,3 +50,1 @@ invariant(

}
export default Index;

@@ -0,4 +1,6 @@

import _keys from 'lodash/object/keys';
import invariant from 'invariant';
import {priorityQueue as PriorityQueue} from 'async';
import Index from './Index';
import DocumentRetriver from './DocumentRetriver';
import PromiseQueue from './PromiseQueue';

@@ -12,10 +14,9 @@

*/
export class IndexManager {
constructor(db, concurrency = 2) {
export default class IndexManager {
constructor(db, options = {}) {
this.db = db;
this.indexes = {};
this.operationQueue = new PriorityQueue(
this._indexOperationWorker.bind(this),
concurrency
);
this._queue = new PromiseQueue({
concurrency: options.concurrency || 2,
});

@@ -76,3 +77,3 @@ // By default ensure index by _id field

const cleanup = () => this.indexes[key].buildPromise = null;
const buildPromise = this._queueOperation(
const buildPromise = this._queue.push(
this._doBuildIndex.bind(this, key),

@@ -94,3 +95,3 @@ 10

return Promise.all(
Object.keys(this.indexes).map(k => {
_keys(this.indexes).map(k => {
return this.ensureIndex({

@@ -110,3 +111,3 @@ fieldName: k,

removeIndex(key) {
return this._queueOperation((resolve, reject) => {
return this._queue.push((resolve, reject) => {
delete this.indexes[key];

@@ -123,4 +124,4 @@ resolve();

indexDocument(doc) {
return this._queueOperation((resolve, reject) => {
const keys = Object.keys(this.indexes);
return this._queue.push((resolve, reject) => {
const keys = _keys(this.indexes);
let failingIndex = null;

@@ -150,4 +151,4 @@ try {

reindexDocument(oldDoc, newDoc) {
return this._queueOperation((resolve, reject) => {
const keys = Object.keys(this.indexes);
return this._queue.push((resolve, reject) => {
const keys = _keys(this.indexes);
let failingIndex = null;

@@ -175,4 +176,4 @@ try {

deindexDocument(doc) {
return this._queueOperation((resolve, reject) => {
const keys = Object.keys(this.indexes);
return this._queue.push((resolve, reject) => {
const keys = _keys(this.indexes);
keys.forEach((k) => {

@@ -195,63 +196,20 @@ this.indexes[k].remove(doc);

// Loop through all doucments in the store
// TODO improve performance:
// * deserialize cache
// * store LRU cache
// Loop through all doucments in the storage
const errors = [];
this.db.storage.loaded().then(() => {
this.db.storage.createReadStream()
.on('data', (data) => {
var doc = this.db.create(data.value);
try {
index.insert(doc);
} catch (e) {
errors.push([e, doc]);
}
})
.on('end', () => {
if (errors.length) {
resolve();
} else {
reject(errors);
}
});
});
}
new DocumentRetriver(this.db).retriveAll().then((docs) => {
docs.forEach(doc => {
try {
index.insert(doc);
} catch (e) {
errors.push([e, doc]);
}
});
/**
* Adds given task (index operation) to the queue and
* wrap it with promise.
* Returned promise would be resolved/rejected only when
* given task complete
* @param {Function} task
* @return {Promise}
*/
_queueOperation(task, priority = 1) {
return new Promise((resolve, reject) => {
this.operationQueue.push(
() => new Promise(task),
priority,
(err) => {
if (err) {
reject(err);
} else {
resolve();
}
}
);
if (errors.length) {
resolve();
} else {
reject(errors);
}
});
}
/**
* Worker for execitung queued tasks
* and moving to the next task when operation
* is ready.
* @param {Object} task
* @param {Object} next
*/
_indexOperationWorker(task, next) {
task().then(next, next);
}
}
export default IndexManager;

@@ -0,1 +1,3 @@

import _keys from 'lodash/object/keys';
import PromiseQueue from './PromiseQueue';
import EventEmitter from 'eventemitter3';

@@ -10,19 +12,33 @@

*/
export class StorageManager {
constructor(options) {
export default class StorageManager {
constructor(db, options) {
this.db = db;
this._queue = new PromiseQueue();
this._storage = {};
this.reload();
}
loaded() {
return Promise.resolve();
return this._loadedPromise;
}
reload() {
if (this._loadedPromise) {
this._loadedPromise = this._loadedPromise.then(() => {
return this._loadStorage();
});
} else {
this._loadedPromise = this._loadStorage();
}
}
destroy() {
return this._loadedPromise.then(() => {
this._storage = {};
});
}
persist(key, value) {
return new Promise((resolve, reject) => {
try {
this._storage[key] = value;
resolve();
} catch (e) {
reject(e);
}
return this._loadedPromise.then(() => {
this._storage[key] = value;
});

@@ -32,9 +48,4 @@ }

delete(key) {
return new Promise((resolve, reject) => {
try {
delete this._storage[key];
resolve();
} catch (e) {
reject(e);
}
return this._loadedPromise.then(() => {
delete this._storage[key];
});

@@ -44,8 +55,4 @@ }

get(key) {
return new Promise((resolve, reject) => {
try {
resolve(this._storage[key]);
} catch (e) {
reject(e);
}
return this._loadedPromise.then(() => {
return this._storage[key];
});

@@ -57,11 +64,15 @@ }

process.nextTick(() => {
Object.keys(this._storage).forEach((k) => {
emitter.emit('data', {value: this._storage[k]});
this._loadedPromise.then(() => {
_keys(this._storage).forEach((k) => {
emitter.emit('data', {value: this._storage[k]});
});
emitter.emit('end');
});
emitter.emit('end');
});
return emitter;
}
_loadStorage() {
return Promise.resolve();
}
}
export default StorageManager;
{
"name": "marsdb",
"version": "0.2.0",
"version": "0.2.1",
"author": {

@@ -9,7 +9,5 @@ "name": "Artem Artemev",

"contributors": [
"Artem Artemev",
"Louis Chatriot",
"Ivo Georgiev"
"Artem Artemev"
],
"description": "Model-oriented embedded database, inspired by LinvoDB & MongoDB, over LevelUP interface",
"description": "MarsDB is a lightweight client-side MongoDB-like database, Promise based, written in ES6",
"keywords": [

@@ -31,2 +29,3 @@ "database",

"async": "1.4.2",
"core-js": "^1.2.2",
"eventemitter3": "1.1.1",

@@ -39,5 +38,9 @@ "geojson-utils": "^1.1.0",

"devDependencies": {
"fbjs-scripts": "^0.2.2",
"babel": "^5.8.23",
"babel-eslint": "^4.1.1",
"babelify": "^6.3.0",
"brfs": "^1.4.1",
"browserify": "^11.2.0",
"bulk-require": "^0.2.1",
"bulkify": "^1.1.1",
"chai": "^3.2.0",

@@ -47,15 +50,25 @@ "chai-as-promised": "^5.1.0",

"del": "^2.0.2",
"envify": "^3.4.0",
"fbjs-scripts": "^0.2.2",
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"gulp-eslint": "^1.0.0",
"istanbul": "^0.3.22",
"gulp-if": "^2.0.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.4.2",
"istanbul": "^0.4.0",
"mocha": "^2.3.2",
"mocha-lcov-reporter": "^1.0.0",
"mocha-phantomjs": "^4.0.1",
"require-dir": "^0.3.0",
"run-sequence": "^1.1.2"
"run-sequence": "^1.1.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"scripts": {
"test": "mocha --require babelhook --reporter spec --timeout 10000",
"coverage": "istanbul cover _mocha --require babelhook test -- -u exports -R spec && open coverage/lcov-report/index.html",
"coveralls": "istanbul cover _mocha --require babelhook test --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
"test_some": "mocha --require babelhook --reporter spec --timeout 10000",
"test_browser": "gulp build:browser:tests && mocha-phantomjs --reporter spec browser_tests.html",
"test": "mocha --require babelhook --reporter spec --timeout 10000 test/both test/node",
"coverage": "istanbul cover _mocha --require babelhook test/both test/node -- -u exports -R spec && open coverage/lcov-report/index.html",
"coveralls": "istanbul cover _mocha --require babelhook test/both test/node --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},

@@ -62,0 +75,0 @@ "main": "index",

@@ -0,42 +1,144 @@

<div style="text-align:center"><img src="https://static.studytime.me/marsdb.png" /></div>
MarsDB
=========
[![Build Status](https://travis-ci.org/c58/marsdb.svg?branch=master)](https://travis-ci.org/c58/marsdb) [![npm version](https://badge.fury.io/js/marsdb.svg)](https://www.npmjs.com/package/marsdb) [![Coverage Status](https://coveralls.io/repos/c58/marsdb/badge.svg?branch=master&service=github)](https://coveralls.io/github/c58/marsdb?branch=master) [![Dependency Status](https://david-dm.org/c58/marsdb.svg)](https://david-dm.org/c58/marsdb)
[![Build Status](https://travis-ci.org/c58/marsdb.svg?branch=master)](https://travis-ci.org/c58/marsdb)
[![npm version](https://badge.fury.io/js/marsdb.svg)](https://www.npmjs.com/package/marsdb)
[![Coverage Status](https://coveralls.io/repos/c58/marsdb/badge.svg?branch=master&service=github)](https://coveralls.io/github/c58/marsdb?branch=master)
MarsDB is a lightweight client-side database.
It based on a Meteor’s `minimongo` mathing/modifying implementation. It carefully written on `ES6`, usess `modular lodash`, have a `Promise` based interface and may be backed with any storage implementation (LevelUP, LocalStorage, IndexDB, etc). It also supports `observable` cursors.
MarsDB is a Node.js/NW.js/Electron persistent, promise base
DB with MongoDB features and very close interface. It's originally
base on LinvoDB3, which based on NeDB. Writen on ES6 and highly
extendable.
MarsDB supports any kind of find/update/remove operations that Meteor’s minimongo does. So, go to the Meteor docs for supported query/modifier operations.
### Features:
You can use it in any JS environment (Browser, Electron, NW.js, Node.js).
* **Promise based**
## Features
* **Promise based API**
* **Carefully written on ES6**
* **MongoDB-like query language**
* **Flexible request pipeline** – map, reduce, join, etc.
* **Object joins** – simplest client-side joins ever
* **Persistence** with interface, compiatble with LevelUP
* **NW.js/Electron friendly** - JS-only backend is [Medea](https://github.com/medea/medea)
* **Performant** - steady performance unaffected by DB size - queries are always indexed
* **Auto-indexing**
* **Live queries** - make the query, get constantly up-to-date results
* **Efficient Map / Reduce / Limit**
* **Supports many of MeteorDB query/modify operations** – thanks to Meteor’s minimongo
* **Flexible pipeline** – map, reduce, custom sorting function, filtering. All with a sexy JS interface (no ugly mongo’s aggregation language)
* **Joinable cursor** – joining one object with another can’t be simplier
* **Persistence API** – all collections can be stored (and restored) with any kind of storage (in-memory, LocalStorage, LevelUP, etc)
* **Live queries** - just like in Meteor, but with simplier interface
Not supported query edge cases
-------------
Not all edge cases supported. See `test/IndexMatcher.test.js` for more info
* $gt()e and $lt(e) object argumen. Only number argument works correctly
* RegExp in document is not match anything
* RegExp in selector in array not works (ex. {a: ['a', /b/i]})
* Some null and undefined checks
* Reguesting for documents with arrays with mixed types (ex. {a: [1, {a:2}, null]})
## Examples
### Create a collection
```javascript
import Collection from ‘marsdb’;
import LocalStorageManager from 'marsdb/lib/LocalStorageManager';
Status
-------------
Work in progress
// Setup different id generator and storage managers
// Default storage is in-memory
Collection.defaultStorageManager(LocalStorageManager);
Collection.defaultIdGenerator(() => {
return {
value: Math.random(),
seed: 0,
};
});
License
-------------
const users = new Colelction(‘users’);
```
### Find a documents
```javascript
const posts = new Colelction(‘posts’);
posts.find({author: ‘Bob’})
.sort([‘createdAt’])
.then(docs => {
// do something with docs
});
```
### Find with pipeline (map, reduce, filter)
An order of pipeline methods invokation is important. Next pipeline operation gives as argument a result of a previous operation.
```javascript
const posts = new Colelction(‘posts’);
posts.find()
.limit(10)
.sortFunc((a, b) => a - b + 10)
.filter(doc => Matsh.sqrt(doc.comment.length) > 1.5)
.map(doc => doc.comments.length)
.reduce((acum, val) => acum + val)
.thene(result => {
// result is a sum of coutn of comments
// in all found posts
});
```
### Find with observing changes
Observable cursor returned only by a `find` method of a collection. Updates of the cursor is batched and debounced (default batch size is `20` and debounce time is `1000 / 15` ms). You can change the paramters by `batchSize` and `debounce` methods of an observable cursor (methods is chained).
```javascript
const posts = new Colelction(‘posts’);
const stopper = posts.find({tags: {$in: [‘marsdb’, ‘is’, ‘awesome’]}})
.observe(docs => {
// invoked on every result change
// (on initial result too)
stopper.stop(); // stops observing
}).then(docs => {
// invoked once on initial result
// (after `observer` callback)
});
```
### Find with joins
Joined objects is not obervable yet.
```javascript
const users = new Colelction(‘users’);
const posts = new Colelction(‘posts’);
posts.find()
.join(doc => {
// Return a Promise for waiting of the result
return users.findOne(doc.authorId).then(user => {
doc.authorObj = user;
});
})
.join(doc => {
// Also any other “join” mutations supported
doc.another = _cached_data_by_post[doc._id];
});
```
### Inserting
```javascript
const posts = new Colelction(‘posts’);
posts.insert({text: ‘MarsDB is awesome’}).then(docId => {
// Invoked after persisting document
})
posts.insertAll(
{text: ‘MarsDB’},
{text: ‘is’},
{text: ‘awesome’}
).then(docsIds => {
// invoked when all documents inserted
});
```
### Updating
```javascript
const posts = new Colelction(‘posts’);
posts.update(
{authorId: {$in: [1, 2, 3]}},
{$set: {text: ‘noop’}}
).then(result => {
console.log(result.modified) // count of modified docs
console.log(result.updated) // array of updated docs
console.log(result.original) // array of original docs
});
```
### Removing
```javascript
const posts = new Colelction(‘posts’);
posts.remove({authorId: {$in: [1,2,3]}})
.then(removedDocs => {
// do something with removed documents array
});
```
## Roadmap
* Keep track of multiple remove/update documents in selector (allow only if opations.multi passed)
* Upsert updating
* Indexes support for some kind of simple requests {a: '^b'}, {a: {$lt: 9}}
* Some set of backends
* Documentation
## Contributing
I’m waiting for your pull requests and issues.
Don’t forget to execute `gulp lint` before requesting. Accepted only requests without errors.
## License
See [License](LICENSE)

@@ -1,2 +0,2 @@

import Model from '../lib/Model';
import Collection from '../lib/Collection';
import IndexManager from '../lib/IndexManager';

@@ -13,3 +13,3 @@ import Index from '../lib/Index';

beforeEach(function () {
db = new Model('test')
db = new Collection('test')
idxMan = db.indexManager;

@@ -16,0 +16,0 @@ });

import documentMatchingTest from './MatchingTests';
import IndexMatcher, * as IndexMatcherInternals from '../lib/IndexMatcher';
import EJSON from '../lib/EJSON';
import Model from '../lib/Model';
import Collection from '../lib/Collection';
import Index from '../lib/Index';

@@ -76,3 +76,3 @@ import async from 'async';

beforeEach(function () {
db = new Model('test');
db = new Collection('test');

@@ -118,3 +118,3 @@ return Promise.all([

var matches = function (shouldMatch, selector, doc) {
const db = new Model('test');
const db = new Collection('test');
return db.insert(doc).then((result) => {

@@ -121,0 +121,0 @@ return db.find(selector);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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