Dexie.js icon indicating copy to clipboard operation
Dexie.js copied to clipboard

Does dexie supports "CASE INSENSITIVE" sorting?

Open pugazhendhisp opened this issue 7 years ago • 5 comments

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.

pugazhendhisp avatar Nov 02 '18 12:11 pugazhendhisp

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.

dfahlander avatar Nov 02 '18 14:11 dfahlander

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

pugazhendhisp avatar Sep 20 '19 14:09 pugazhendhisp

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

ancill avatar Dec 02 '22 10:12 ancill

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.

dfahlander avatar Dec 02 '22 14:12 dfahlander

@dfahlander Hey, Is this still the case today?

saif-o99 avatar Apr 10 '25 06:04 saif-o99