Querying on multiple keys (range on one of them) with indexedb or ydn

喜夏-厌秋 提交于 2019-12-11 08:23:33

问题


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

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.


回答1:


Prefix key query, as you described above, is very fast and recommended for key-value store filtered query.

You can query as follow:

key_range = IDBKeyRange.bound([a, b, c], [a, b, d], true, true);

or in ydn-db

key_range = ydb.db.KeyRange.bound([a, b, c], [a, b, d], true, true);


来源:https://stackoverflow.com/questions/21789595/querying-on-multiple-keys-range-on-one-of-them-with-indexedb-or-ydn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!