dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.68k stars 642 forks source link

Does dexie supports "CASE INSENSITIVE" sorting? #764

Open pugazhendhisp opened 6 years ago

pugazhendhisp commented 6 years ago

As my use case here, i want result set to be sort by "fullName" with caseinsensitive, as far as i know , dexie doesn't support caseinsentive sorting.

db.transaction('rw!',db["contacts"], function(){ 
    var query = db["contacts"].where(index).equals(indexValue);
    query.offset(offset).limit(limit).sortBy("fullName").then(function(data){
        deferred.resolve(data);
    }).catch(function(err){
        deferred.reject({'error' : err}); 
    });
});

is there any way to achieve this.

dfahlander commented 6 years ago

No, Dexie does not support that out-of-the-box.

There are two ways to accomplish it. If you require not only case insensitive but locale specific sorting, you'd probably go for retrieving all items (toArray()) and then sort the resulting array according to a specific Intl.Collator.

If on the other hand, you only want default non-case sensitive sorting, your could do that as well, but if you want to utilize the IndexedDB index for sorting (if you have large number of rows and want to show page by page), you might be better of storing a lowercase version of the property and index that property rather than the one containing the exact spelling.

pugazhendhisp commented 5 years ago

Hi @dfahlander, i really appreciate your response, Thanks and pardon me for delayed response on your answer.

ancill commented 1 year ago

@dfahlander Hi! Thanks for your work! Is it any updates since then on this feature?

dfahlander commented 1 year ago

No updates on any released version. Lots of ideas though regarding tricking indexeddb to sort in locale specific, case and accent insensitive order. I'll see what can be included in 4.0.