user2738707
user2738707

Reputation: 125

IndexedDB range limits

I'm using IndexedDb to store a person's city, email id and created_at. I want to get all the people in a for a certain city with a valid email and sort by the created_at date.

I have a compound index query like so:

var     city = "chennai";
var     index_name = "city, " + "email, " + "created_at";
var     index   = store.index(index_name);
var     boundedKeyRange = IDBKeyRange.bound([city, "", 0], [city, ??, ""]);

index.openCursor(boundedKeyRange, "prev").onsuccess = function(e) {
    var cursor = e.target.result;

    if  (cursor) {
         // Check if email is valid and add it to an array
    }
    else {
          // resolve a promise
    }
}

The problem I have is that I don't know how to set the 'upper range' for email id's since @ is a special character I'm not sure set the upper range to have all the email ids in the query.

Thank you

Deepak

Upvotes: 0

Views: 134

Answers (1)

Kyaw Tun
Kyaw Tun

Reputation: 13151

The upper bound of a string can be taken as '\uFFFF' or [].

Anyways, your query will not work because you have two range query, "email" and "created_at". You can have only one key range query.

Upvotes: 1

Related Questions