我猜是一个容易的。在 mongo shell 上执行时:
db.topic.find({"user_id":ObjectId("52e39be16700006700d646ad"), "post_id":null})
它将列出 post_id 为空或不存在的所有主题。这工作正常。
但是,当使用 Scala 代码时,我尝试以下不起作用:
val cursor = db("topic").find(
BSONDocument("user_id" -> user.id),
BSONDocument("post_id" -> null)).cursor[Topic]
cursor.collect[List]()
基本上我必须更改条件 BSONDocument("post_id" -> null)。但是怎么做?
非常感谢!马塞尔