Pouchdb文档ID复杂密钥 [英] Pouchdb document id complex key
问题描述
我知道可以使用复杂的键(基本上是数组)构建视图。
I know views can be built using complex keys (an array basically).
但是,普通文档也支持吗?我想避免使用视图,因为许多文档在手机上的性能可能会非常缓慢。因此,我正在使用使用和滥用密钥方法。
But, do normal documents also support that? I want to avoid views as performance on phones can be very slow with many many docs. So I'm using the "Use and abuse your keys" approach.
这就是为什么我需要复杂的键,以便可以使用 startkey
和 endkey的原因
。
So that is why I would need complex keys so I can use startkey
and endkey
on those.
推荐答案
是的,完全有可能。阅读此博客文章,请跳过使用和滥用您的文档ID。
Yep, it's totally possible. Read this blog post, skip to "use and abuse your doc ids."
基本上,您要做的是使用 PouchDB Collate 插件将您的复杂密钥序列化为字符串,然后将其用于 _id
。然后使用 startkey
, endkey进行查找与使用
, query()
API完全相同键
,随您便。
Basically what you do is use the PouchDB Collate plugin to serialize your complex key into a string, and then use that for the _id
. Then lookups work exactly the same as with the query()
API, using startkey
, endkey
, keys
, whatever you like.
这篇关于Pouchdb文档ID复杂密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!