![](/img/trans.png)
[英]MongoDB Compass: How to filter embedded array object in the MongoDB document
[英]How to view an object embedded with a document in mongodb
> db.orders.find({})
{ "_id" : ObjectId("5b78b933d62e262ddb055509"), "user_id" : "5b16d96a74be42566844e0b4", "game_id" : "5b11c56c6c71dc44976fba55", "seats" : { "_id" : ObjectId("5b78b933d62e262ddb05550a") }, "__v" : 0 }
{ "_id" : ObjectId("5bb135638625d21c0883fe1d"), "user_id" : "5b16d96a74be42566844e0b4", "game_id" : "5b11c56c6c71dc44976fba61", "seats" : { "_id" : ObjectId("5bb135638625d21c0883fe1e") }, "__v" : 0 }
上面是在我的Mongo實例中存儲的訂單上的find命令的輸出。
座位是嵌入在訂單模式中的對象數組。 如何查看和獲取存儲在對象席位中的數組?
seats
是一個交叉引用字段,其中包含花葯集合的ObjectId。
您在使用貓鼬嗎? 如果是這樣,則需要使用填充方法來填充find
等對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.