我在项目中使用MongoDB Atlas。我试图建立查询,但是遇到了一些问题。
select top 20 *
from users
where _id not in (select following=0
from users
where _id = myuserid)
我尝试转换查询,但不能。
"{\"collection\":\"users\",\"stages\":[{\"$match\":{\"$and\":[{\"status\":\"active\"},{\"_id\":{\"$ne\":{\"$oid\":[{\"$match\":[{\"_id\":{\"$oid\":\"%%args.user\"}},{\"following\":{\"$size\":0}}]},{\"$project\":{\"_id\":1}}]}}}]}}]}"
您能帮我解决问题吗?。
谢谢。
答案 0 :(得分:0)
可以通过以下方式完成:
db.collection.find({
userid: {
$ne: myuserid
}
}).limit(20)