我有以下文档结构:
{
"_id": ObjectId("52caafa2eccc222244f242cc"),
"fields": {
$id: ObjectId("52caafa2eccc222244f242cc"),
$db: 'other_db',
$ref: CollectionName
}
}
我正在尝试将所有{id,fields.id}投影如下:
db.Collection.find({},{"_id": 1, "fields._id": 1});
但没有任何结果
答案 0 :(得分:0)
错误的文档结构,在阅读@yogesh建议的MongoDb Reference Documentation之后,问题是由$
每个Reference
键的SELECT title, COUNT(actorid) AS actors FROM movie
JOIN casting ON id = movieid
WHERE yr = 1978
GROUP BY title
ORDER BY actors DESC
登录引起的。