|
|
@ -134,12 +134,33 @@ Index.prototype.update = function (oldDoc, newDoc) { |
|
|
|
* For now only works with field equality (i.e. can't use the index for $lt query for example) |
|
|
|
* For now only works with field equality (i.e. can't use the index for $lt query for example) |
|
|
|
* And doesn't return non indexed docs |
|
|
|
* And doesn't return non indexed docs |
|
|
|
* @param {Thing} value Value to match the key against |
|
|
|
* @param {Thing} value Value to match the key against |
|
|
|
* @return {Array od documents} |
|
|
|
* @return {Array of documents} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Index.prototype.getMatching = function (value) { |
|
|
|
Index.prototype.getMatching = function (value) { |
|
|
|
return this.tree.search(value); |
|
|
|
return this.tree.search(value); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get all elements in the index |
|
|
|
|
|
|
|
* @return {Array of documents} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Index.prototype.getAll = function () { |
|
|
|
|
|
|
|
var res = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.tree.executeOnEveryNode(function (node) { |
|
|
|
|
|
|
|
var i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < node.data.length; i += 1) { |
|
|
|
|
|
|
|
res.push(node.data[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Interface
|
|
|
|
// Interface
|
|
|
|
module.exports = Index; |
|
|
|
module.exports = Index; |
|
|
|