= ' a' order by indexB ASC limit 10"?-6ren"> = ' a' order by indexB ASC limit 10"?-目前我正在学习javascript IndexedDB,我发现使用它时我无法进行复杂的查询。现在我想做一个选择查询,例如 “从表中选择*,其中indexA >= 'a'按indexB ASC限制10排-6ren">
gpt4 book ai didi

javascript - 如何在indexedDB中执行 "select * from table where indexA >= ' a' order by indexB ASC limit 10"?

转载 作者:行者123 更新时间:2023-12-03 06:44:30 25 4
gpt4 key购买 nike

目前我正在学习javascript IndexedDB,我发现使用它时我无法进行复杂的查询。现在我想做一个选择查询,例如
“从表中选择*,其中indexA >= 'a'按indexB ASC限制10排序”

我尝试使用
store.createIndex("indexA,indexB",["indexA","indexB"])
并尝试提出请求
store.index("indexA, indexB").openCursor(IDBKeyRange.lowerBound([1, "a"], true))
然而结果仅根据索引A排序。有什么办法可以做到吗?

最佳答案

你必须自己滚动这个。基本上有两种方法:

  • 像您所做的那样,在“indexA”上使用索引,打开一个下限为“a”的游标并进行迭代,累积所有结果,然后按 indexB 排序,并选择前 10 个。
  • 在“indexB”上使用索引,打开游标并迭代,跳过 indexA <“a”的任何条目,并在遇到 10 后停止。

链接的主题(谢谢其他 Josh!)提供了更多详细信息。

关于javascript - 如何在indexedDB中执行 "select * from table where indexA >= ' a' order by indexB ASC limit 10"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37807022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com