[英]Add to list within document MongoDB
I have a database where I store player names that belong to people who have certain items. 我有一个数据库,用于存储属于某些物品的玩家的玩家名称。 The items have and IDs, and subIDs. 这些项目具有和ID,以及子ID。 The way I am currently storing everything is: 我目前存储所有内容的方式是:
Each ID has its own collection 每个ID都有自己的集合
Within the collection there is a document for each subID. 在集合中,每个子ID都有一个文档。 The document for each subID is layed out like so: 每个subID的文档布局如下:
{ "itemID":itemID, "playerNames":[playerName1, playerName2, playerName3] } {“ itemID”:itemID,“ playerNames”:[playerName1,playerName2,playerName3]}
I need to be able to add to the list of playerNames quickly and efficiently. 我需要能够快速有效地添加到playerNames列表中。
Thank you! 谢谢!
If I understood your question correctly, you need to add items to the "playerNames" array. 如果我正确理解了您的问题,则需要将项目添加到“ playerNames”数组中。 You can use one of the following operators: 您可以使用以下运算符之一:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.