[英]$nin with $and in mongoose
使用貓鼬操作過濾用戶(管理員)。
他需要查看所有已保存的文件……除草稿文件外。
但是他又應該能夠看到自己保存的草稿文件...
filter = {
'_id':
$nin://not in (dont show)
[{
$and:
[
// {_id : _id},//in this id and
{createBy: {$ne: userId}},//other dan admin and
{status: {$regex: /draft/, $options: 'm'}} //save as draft
]
}]
}
我嘗試通過這種方式進行過濾,但此錯誤結束了。
exceptionMongoError:無法規范化查詢:BadValue未知頂級運算符:$ nin
提前致謝...
您只需要查找由用戶或非草稿者創建的文檔:
files.find({$or: [{createBy: userId}, {status: /^((?!draft).)*$/}]})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.