IndexedDB中的多键查询(类似于sql中的OR) [英] Multiple keys query in IndexedDB (Similar to OR in sql)
问题描述
我在标签上存储了multiEntry索引.
I have store with multiEntry index on tags.
{ tags: [ 'tag1', 'tag2', 'tag3' ] }
我也查询了标签列表.
[ 'tag2', 'tag1', 'tag4' ]
我需要获取所有包含查询中的标记之一的记录(类似于SQL OR语句).
I need to get all records which contain one of tag in query (Similar to SQL OR statement).
目前,除了遍历查询中的标签并按商店中的每个标签进行搜索之外,我找不到其他解决方案.
Currently I cannot find any other solution except iterate over tags in query and search by the each tag in the store.
有没有更好的解决方案?
Is there any better solution?
谢谢.
推荐答案
除迭代外,您无法通过一个查询来检索所有结果.您可以通过打开从最低值到最高值的索引来优化搜索结果:
You cannot retrieve all results with one query except with iteration. You can optimize the search result by opening a index from the lowest value to the highest:
IDBKeyRange.bound ('tag1', 'tag4');
您可以使用的其他Indexed-Db功能是打开多个查询,并在查询完成后合并结果.这样会比迭代快得多.
Other Indexed-Db feature you can use is to open multiple queries and combine the result when the queries complete. This way would be much faster than the iteration.
这篇关于IndexedDB中的多键查询(类似于sql中的OR)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!