我正在尝试使用pouchdb.find但继续获取未知的操作符错误。
{"message":"unknown operator \"$or\" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type or $all"}
我有点迷失,因为我读过的所有文件都说$或者是可用的。
的package.json:
"pouchdb": "^6.3.4",
"pouchdb-find": "^6.3.4",
JavaScript的:
db.find({
selector: {
type: 'question',
tags: { $or: [ '202', '206' ] }
},
use_index: 'tagSearch',
include_docs: true
}).then()...
我有一种感觉,我错过了一些基本的东西。我正在寻找检索选择器中列出的一个或另一个标签的所有文档。任何帮助/方向将不胜感激。
我想你可能需要对其进行重组。
我在我的发现中做了一个AND,让它像这样设置 -
db.find({
selector: {
$and: [
{ type: { $exists: true } },
{ type: { $eq: "sessions" } },
{ start_date: { $gt: true } },
{ start_date: { $eq: "2018-10-21" } }
]
}
你们很多人都需要这样的东西(没有测试它,不确定这是正确的语法。
db.find({
selector: {
type: 'question',
$or: [
{tags: '202'},
{tags: '206'},
]
}
})
或者你可以尝试使用IN
selector: {
tags: {
$in: [ "202", "206" ]
}
}
家里的一些帮助。