LokiJS: Querying empty collection with binary index throws error
If a collection has a binary index set, and the collection is empty, querying it will result in an error. The error happens in the calculateRange function on the following lines:
var minVal = rcd[index[min]][prop];
var maxVal = rcd[index[max]][prop];
If the collection is empty, then rcd[index[min/max]] will be undefined. We may want to set default min and max values here, but also, maybe shortcut the find() function to return an empty result set if the data is empty to save some work.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 32 (3 by maintainers)
I’ve opened a new issue under #654.
(it’s
ensureAllIndexes(true), notensureAllIndices(true)BTW.