我是MongoDb的初学者。尝试了很多,但停留在一个查询上。 请在以下给定的示例中找到mongo文档示例:
job1:
image: <image to use,overriding the default set by the runner>
script: "<do something>"
tags:
- general
在以下情况下,我只希望选择字段: 酒店ID为45,入住价格为1,is_active为false,状态为Pending,计划类型为['AP','EP']。 所需的输出:
{
"_id" : ObjectId("5dc158a60566e14c5190db72"),"hotel_id" : NumberInt(45),"plans" : [
{
"plan_type" : "AP","sub_plans" : [
{
"channels" : [
{
"channel_name" : "default","status" : "Pending","is_active" : false,"start_date" : NumberLong(1468521000000),"end_date" : NumberLong(1901125800000),"non_veg_available" : null,"oyo_commission" : 20.0,"ep_price_reduction" : null,"salesforce_id" : "a0Y280000023LFwEAM","breakfast_start_time" : null,"breakfast_end_time" : null,"lunch_start_time" : null,"lunch_end_time" : null,"dinner_start_time" : null,"dinner_end_time" : null,"created_at" : NumberLong(1468577718000),"updated_at" : NumberLong(1481074321000),"prices" : [
{
"occupancy" : NumberInt(1),"guest_type" : null,"veg_price" : NumberInt(400),"non_veg_price" : null,"additional_non_veg_price" : null,"discount" : null
}
]
},{
"channel_name" : "default","salesforce_id" : "a0W28000004GqL4","breakfast_start_time" : "7:30","breakfast_end_time" : "10:00","lunch_start_time" : "12:30","lunch_end_time" : "15:00","dinner_start_time" : "19:00","dinner_end_time" : "22:30","created_at" : NumberLong(1505516604000),"updated_at" : NumberLong(1505516604000),"veg_price" : NumberInt(425),"non_veg_price" : NumberInt(425),"additional_non_veg_price" : 0.0,"created_at" : NumberLong(1505709978000),"updated_at" : NumberLong(1542162045000),"discount" : null
}
]
}
],"sub_plan_type" : "Standard","is_sub_plan_default" : false
}
]
},{
"plan_type" : "EP","oyo_commission" : null,"ep_price_reduction" : NumberInt(80),"salesforce_id" : "a0Y280000023LG1EAM","veg_price" : null,{
"plan_type" : "MAP","salesforce_id" : "a0Y280000023LG6EAM","veg_price" : NumberInt(200),"updated_at" : NumberLong(1541476001000),"veg_price" : NumberInt(225),"non_veg_price" : NumberInt(225),"is_sub_plan_default" : false
}
]
}
]
}
我的查询
{
"_id" : ObjectId("5dc158a60566e14c5190db72"),"prices" : [
{
"veg_price" : NumberInt(425)
}
]
},"prices" : [
{
"veg_price" : NumberInt(425)
}
]
}
],"prices" : [
{
"veg_price" : null,}
]
}
],]
}
注意-我只需要搜索一个酒店ID为45的文档。 请帮忙。 预先感谢。