In progress

pull/2/head
Louis Chatriot 11 years ago
parent 2aae85c0e9
commit b9e9e4cc38
  1. 3
      lib/datastore.js
  2. 2
      lib/indexes.js
  3. 13
      test/indexes.test.js

@ -489,10 +489,11 @@ Datastore.prototype.remove = function () {
this.executor.push({ this: this, fn: this._remove, arguments: arguments }); this.executor.push({ this: this, fn: this._remove, arguments: arguments });
}; };
/* /*
var db = new Datastore({ inMemoryOnly: true }) var db = new Datastore({ inMemoryOnly: true })
//db.ensureIndex({ fieldName: 'tag' }); db.ensureIndex({ fieldName: 'tag' });
db.insert({ tag: ['a', 'b', 'c'] }, function () { db.insert({ tag: ['a', 'b', 'c'] }, function () {
db.find({ tag: 'b' }, function (err, item) { db.find({ tag: 'b' }, function (err, item) {

@ -14,6 +14,8 @@ function checkValueEquality (a, b) {
/** /**
* Create a new index * Create a new index
* All methods on an index guarantee that either the whole operation was successful and the index changed
* or the operation was unsuccessful and an error is thrown while the index is unchanged
* @param {String} options.fieldName On which field should the index apply (can use dot notation to index on sub fields) * @param {String} options.fieldName On which field should the index apply (can use dot notation to index on sub fields)
* @param {Boolean} options.unique Optional, enforce a unique constraint (default: false) * @param {Boolean} options.unique Optional, enforce a unique constraint (default: false)
* @param {Boolean} options.sparse Optional, allow a sparse index (we can have documents for which fieldName is undefined) (default: false) * @param {Boolean} options.sparse Optional, allow a sparse index (we can have documents for which fieldName is undefined) (default: false)

@ -120,6 +120,19 @@ describe('Indexes', function () {
assert.deepEqual(idx.tree.search('world'), []); assert.deepEqual(idx.tree.search('world'), []);
assert.deepEqual(idx.tree.search('bloup'), []); assert.deepEqual(idx.tree.search('bloup'), []);
}); });
describe.only('Array fields', function () {
it('Inserts one entry per unique array element in the index', function () {
var obj = { arr: [], really: 'yeah' }
, idx = new Index({ fieldName: 'tf' })
;
idx.insert(obj);
});
}); // ==== End of 'Array fields' ==== //
}); // ==== End of 'Insertion' ==== // }); // ==== End of 'Insertion' ==== //

Loading…
Cancel
Save