PouchDB 的 find() 总是说 "no matching index" 即使我做了一个

PouchDB's find() always says "no matching index" even if I make one

给定一个新数据库:

db = PouchDB('testing @ '+new Date().getTime() );

还有一个新索引

await db.createIndex({
    index: {fields: ['type']}
});

按该索引查找所有文档:

await db.find({
    selector: {
        type:'hip',
    },
    sort: [{'_id':'desc'}], 
})

总是在结果中包含警告 "no matching index found"。

您的查询取决于两个字段:type_id。但是你的索引只提供了一个:type.

要使用 Mango 查询进行排序,您的排序列也必须建立索引。

您的选择器还需要引用排序列。这可以在不影响结果集的情况下通过添加如下内容来完成:

_id: {"$gte": null}