仅MongoDB runcommand值
我正在尝试执行mongoDB runcommand查询,作为输出,我只想要该值。目前,其返回的嵌套属性名称。
示例匹配记录:
{
"_id":"123",
"name": "Emp1",
"department": {
"deptName":"dept1",
"type": "xyz"
}
}
查询我正在尝试:
db.employee.runCommand( {
find: db.employee.getName(),
filter: {'name':'Emp1','_id':'123'},
projection: {_id:0,'department.deptName':1}
});
查询响应:
{
"cursor": {
firstBatch" : [
{
"department":{
"deptName":"dept1"
}
}
],
.
.
.
.
}
有什么方法可以从属性中跳过父母名称,并直接获取部门名称,就像
"firstBatch" : [ {
"deptName":"dept1"
}
]
任何指针都会有所帮助一样。
谢谢。
I am trying to execute a MongoDB runCommand query and as an output I only want the value. Currently its returning nested attributes name too.
Sample matching record:
{
"_id":"123",
"name": "Emp1",
"department": {
"deptName":"dept1",
"type": "xyz"
}
}
Query I am trying:
db.employee.runCommand( {
find: db.employee.getName(),
filter: {'name':'Emp1','_id':'123'},
projection: {_id:0,'department.deptName':1}
});
Query Response:
{
"cursor": {
firstBatch" : [
{
"department":{
"deptName":"dept1"
}
}
],
.
.
.
.
}
Is there any way I can skip the parent name from attribute and get the department name directly like
"firstBatch" : [ {
"deptName":"dept1"
}
]
Any pointers will be helpful.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论