0

I am using Dexie

var db = new Dexie('name');
db.version(4)
.stores({
  sentence: "&sentenceId, [sentence__authorId+sentenceChapter+sentenceNo], sentenceContent, headingContent, sentenceStarts, sentenceEnds"
  )};

and I need to get the result sorted by sentenceNo

db.sentence.where('[sentence_authorId+sentenceChapter+sentenceNo]')
.between([articleId, chapter_selected.toString(), -Infinity], [articleId, chapter_selected.toString(), '\uffff'])
.each (function (sentence) {
//............
});

but the result I get from the above query is like sorting an integer column in string format

eg: 1,11,12,13,14...

how to sort sentenceNo in integer

eg : 1,2,3,4,...

ajith
  • 41
  • 2
  • 8

1 Answers1

0

Are you sure that sentenceNo are not stored as strings instead of numbers? IndexedDB enumerate your index in respect to its types.

If you're certain that typeof sentanceNo === 'number', the only thing I could think of would be if you're using a Safari < 10 with IndexedDBShim - theoretically, the shim could have this kind of bug, but that is just a theory.

Vao Tsun
  • 47,234
  • 13
  • 100
  • 132
David Fahlander
  • 5,058
  • 1
  • 20
  • 19
  • sorry the problem isn't dexie it's caused by json request, and the json generated from a mysql database result and mysql gives all result in string that caused the error. – ajith Nov 30 '16 at 17:01