我刚刚发现了 RxDb,据我所知,它在下面运行 PouchDB,无论如何,我已经为实体定义了一个相当简单的模式:
let nodeSchema: RxJsonSchema<NodeDocType> = {
version: 0,
title: `node schema`,
description: `Describes a node`,
type: `object`,
properties: {
id: {
type: `string`,
primary: true,
},
type: {
type: `string`,
},
createdAt: {
type: `number`,
},
updatedAt: {
type: `number`,
},
text: {
type: `string`,
},
name: {
type: `string`,
},
originalUrl: {
type: `string`,
},
localUrl: {
type: `string`,
},
webUrl: {
type: `string`,
},
extension: {
type: `string`,
},
},
required: [`type`, `createdAt`, `updatedAt`],
}
现在的问题是,当我从组件中查询集合并尝试应用排序时,如下所示:
db.nodes
.find()
.sort({
createdAt: `asc`
})
.$.subscribe((nodes) => {
if (!nodes) {
return
}
setNodes(nodes)
})
我收到一条错误消息cannot sort on field(s) XXX when using the default index
,据我目前所见,这与该字段不属于选择器有关吗?但它仍然令人困惑并且无法让它工作,有人知道我做错了什么吗?