看到在 MongoDb 中使用 $pull 的所有解决方案,RxDb 激发了它的查询,这让我很头疼。我开始研究文档,我看到 RxDb 使用 modifyjs。是的...它不支持 $pull 运算符,所以它只留下 $unset 但它只适用于对象属性,而不是删除整个对象。有我的 json 模式:
const sectionSchema = {
keyCompression: true,
version: 0,
type: 'object',
properties: {
sectionTitle: {
type: 'string',
},
lessons: {
type: 'array',
default: [],
items: {
type: 'object',
properties: {
lessonTitle: {
type: 'string',
},
},
},
},
},
};
这是我最接近的解决方案,但它删除了所有课程而不是一个。
doc.update({
$unset: {
lessons: {
[`${lessonKey}`]: this.lessons[lessonKey],
},
}
})
谢谢你的帮助。