【问题标题】:indexeddb sorting index based on integer valueindexeddb 基于整数值的排序索引
【发布时间】:2017-04-14 06:59:33
【问题描述】:

我正在使用 Dexie

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

我需要得到按sentenceNo排序的结果

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

但是我从上面的查询中得到的结果就像以字符串格式对一个整数列进行排序

例如:1,11,12,13,14...

如何对整数中的句子No进行排序

例如:1,2,3,4,...

【问题讨论】:

    标签: sorting indexeddb dexie


    【解决方案1】:

    您确定 sentenceNo 没有存储为字符串而不是数字吗? IndexedDB 根据其类型枚举您的索引。

    如果你确定 typeof sentanceNo === 'number',我唯一能想到的就是如果你使用带有 IndexedDBShim 的 Safari

    【讨论】:

    • 抱歉问题不是dexie,它是由json请求引起的,并且从mysql数据库结果生成的json和mysql给出了导致错误的所有结果。
    猜你喜欢
    • 2013-02-11
    • 2019-12-08
    • 1970-01-01
    • 2018-06-07
    • 2013-09-07
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 2020-11-12
    相关资源
    最近更新 更多