如何列出 RxDB 集合中的所有文档?

How to list all documents in an RxDB collection?

在 RxDB 中,要列出包含文档的远程数据库中集合中的所有文档,我尝试过:

 myCollection.dump()
  .then(json => console.dir(json));

myCollection.find().exec() // <- find all documents
  .then(documents => console.dir(documents));

来自文档:https://rxdb.info/rx-collection.html#dump https://rxdb.info/rx-document.html#find

但两者都做了一个 _find post with body:

{"selector":{"_id":{}}}

那 return 一个空的文档 [] 数组。在 RxDB 之外执行的相同 _find 选择器也 return 是一个空的文档数组。

如果我使用 myCollection.upsert() 将文档添加到集合中,文档将添加到远程服务器,然后在上述两个调用中显示为响应。但也许仅来自存储在内存中的内容,因为仍然有这个远程 _find POST 和一个空的 docs: [] 响应。因此,在页面刷新时,那些列表调用再次为空。

我正在使用:

    "pouchdb-adapter-http": "7.0.0",
    "rxdb": "8.0.4",
    "rxjs": "6.3.3"

此时,RxDB 不支持远程集合。 您可以将远程数据库同步到本地集合,然后 运行 在那里查询。但是不可能将查询发送到远程并获得结果,就像使用 pouchdb-http-adapter 所做的那样。

您可以继续阅读 rxdb.info,因为主要版本 9.0.0 宣布了多项改进,以更好的方式查询文档字段