Some error handling

pull/2/head
Louis Chatriot 12 years ago
parent f6b764da5c
commit 0a0a597a8b
  1. 7
      lib/datastore.js

@ -186,8 +186,6 @@ Datastore.prototype.getCandidates = function (query) {
var indexNames = Object.keys(this.indexes)
, usableQueryKeys;
if (indexNames.length <= 1) { return this.getAllData(); } // No index defined (except _id), no specific candidate
// For a basic match
usableQueryKeys = [];
Object.keys(query).forEach(function (k) {
@ -203,7 +201,7 @@ Datastore.prototype.getCandidates = function (query) {
// For a $in match
usableQueryKeys = [];
Object.keys(query).forEach(function (k) {
if (query[k].hasOwnProperty('$in')) {
if (query[k] && query[k].hasOwnProperty('$in')) {
usableQueryKeys.push(k);
}
});
@ -215,7 +213,7 @@ Datastore.prototype.getCandidates = function (query) {
// For a comparison match
usableQueryKeys = [];
Object.keys(query).forEach(function (k) {
if (query[k].hasOwnProperty('$lt') || query[k].hasOwnProperty('$lte') || query[k].hasOwnProperty('$gt') || query[k].hasOwnProperty('$gte')) {
if (query[k] && (query[k].hasOwnProperty('$lt') || query[k].hasOwnProperty('$lte') || query[k].hasOwnProperty('$gt') || query[k].hasOwnProperty('$gte'))) {
usableQueryKeys.push(k);
}
});
@ -583,4 +581,5 @@ Datastore.prototype.remove = function () {
module.exports = Datastore;

Loading…
Cancel
Save