webcss / angular-indexedDB

An angularjs serviceprovider to utilize indexedDB with angular
149 stars 99 forks source link

QueryBuilder using the same defaultQueryOptions instance every time. #14

Closed btleedev closed 5 years ago

btleedev commented 10 years ago

indexeddb.js line 94.

var defaultQueryOptions = {
    useIndex: undefined,
    keyRange: null,
    direction: NEXT
};

This is used everytime even when instantiating a new QueryBuilder object at indexeddb.js line 432.

this.result = defaultQueryOptions;

So with two QueryBuilders, they will both share the same instance of this.result. Suggest wrapping defaultQueryOptions in a function that returns a new instance of that object.

webcss commented 10 years ago

First, make sure you create a new instance of QueryBuilder, e.g. myQuery = new QueryBuilder();You modify the default settings by applying your conditions, e.g.myQuery.$lt('20') set a lowerbound range.