如何解决MongoDB的选择方式为:从清单WHERE status =“ A”中选择SELECT _id,size.h
MongoDB的选择方式是:从清单WHERE status =“ A”中选择_id,size.h
db.inventory.insertMany( [
{ item: "journal",status: "A",size: { h: 14,w: 21,uom: "cm" },instock: [ { warehouse: "A",qty: 5 } ] },{ item: "notebook",size: { h: 8.5,w: 11,uom: "in" },instock: [ { warehouse: "C",{ item: "paper",status: "D",qty: 60 } ] },{ item: "planner",size: { h: 22.85,w: 30,qty: 40 } ] },{ item: "postcard",size: { h: 10,w: 15.25,instock: [ { warehouse: "B",qty: 15 },{ warehouse: "C",qty: 35 } ] }
]);
选择:
db.inventory.find( { status: "A" },{ item: 1,status: 1,_id: 0 } )
The operation corresponds to the following SQL statement:
SELECT item,status from inventory WHERE status = "A"
现在我需要选择喜欢
SELECT item,status,size.h from inventory WHERE status = "A"
我只需要它的值
size.h
SQL like :
SELECT size.h from inventory WHERE status = "A"
and the MongoDB shell how can i do it
????????????
解决方法
db.inventory.find( { status: "D" },{ 'size.h': 1,'size.w': 1} )
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。