MongoDB子文档投影 [英] MongoDB Projection of a subdocument
本文介绍了MongoDB子文档投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用MongoDB查询投影作者的名字
How do I project the author's first name using a MongoDB query
{
name: "Wings Of Fire",
author:
{
first: "Abdul",
last: "Kalam"
}
}
推荐答案
You can use dot notation in the field selector to project subdocument fields. In the shell:
db.test.find({}, {'author.first': 1})
这篇关于MongoDB子文档投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文