How do I project the author's first name using a MongoDB query
{
name: "Wings Of Fire",
author:
{
first: "Abdul",
last: "Kalam"
}
}
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})