使用indexedb或ydn查询多个键(其中之一) [英] Querying on multiple keys (range on one of them) with indexedb or ydn
问题描述
我已阅读,重新阅读并再次阅读本文档和无数其他网站,但对于我的一生,我无法弄清楚该如何做.我只是有以下(ydn表示法)
I have read, re-read and read again this document and countless of other sites, but for the life of me I am unable to figure out how to do the following. I simply have the following (ydn notation)
{
name:'index',
keyPath:['int1','int2','int3'],
unique:false,
multiEntry:false
}
并希望按照以下内容运行查询
And want to run a query along the lines of
int1=a and int2=b and int3>c and int3<d
我认为应该足够简单,并且如果在ydn中不可能(或太难),我也可以使用纯indexedDB解决方案(在indexedDB api上也有一些经验,但是甚至找不到方法)与那些).我了解了KeyRange
的工作方式,但找不到任何资源将其与简单的index
结合使用.
Which I believe should be simple enough and if it's not possible in ydn (or too hard) I am fine with a pure indexedDB solution as well (have some experience with indexedDB api's, but can't even find the way to do it with those either). I get how KeyRange
works, but I can't find any resources how to combine it with a simple index
.
推荐答案
如上所述,前缀键查询非常快速,建议用于键值存储过滤查询.
Prefix key query, as you described above, is very fast and recommended for key-value store filtered query.
您可以查询以下内容:
key_range = IDBKeyRange.bound([a, b, c], [a, b, d], true, true);
或在ydn-db
key_range = ydb.db.KeyRange.bound([a, b, c], [a, b, d], true, true);
这篇关于使用indexedb或ydn查询多个键(其中之一)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!