2レベルの複雑さを持つ配列内の要素を取得しようとしています
私の文書:
> db.users.find({ mail : 'titi@toto.fr'}).pretty()
{
"_class" : "bean.User",
"_id" : ObjectId("52f504bb2f9dd91186211537"),
"commandes" : [
{
"adresse" : "15 rue de la soif",
"codePostal" : "29200",
"idCommande" : 1,
"montantTotal" : 0,
"nom" : "TOTO",
"prenom" : "tata",
"ville" : "Brest",
"voyagesSouscrits" : [
{
"idVoyage" : "123",
"duree" : 1,
"nbPersonnes" : 0,
"villeDepart" : "Nantes",
"prixVoyage" : 999999
},
{
"idVoyage" : "addVoyageSouscrit",
"duree" : 1,
"nbPersonnes" : 0,
"villeDepart" : "Toulouse",
"prixVoyage" : 7777
}
]
},
{
"idCommande" : 1,
"dateCommande" : ISODate("2014-02-07T16:07:23.930Z"
),
"nom" : "TOTO",
"prenom" : "tata",
"adresse" : "15 rue de la soif",
"ville" : "Brest",
"codePostal" : "29200",
"montantTotal" : 0,
"voyagesSouscrits" : [
{
"idVoyage" : "123",
"duree" : 1,
"nbPersonnes" : 0,
"villeDepart" : "Toulouse",
"prixVoyage" : 666666
}
]
}
],
"mail" : "titi@toto.fr",
"password" : "tata"
}
最初のステップでは、ID「123」の「voyagesSoucrits」要素を取得します。
この投稿によると: MongoDBは、配列の2レベルの深さから要素をプルします
私は試した :
> db.users.update({ mail : 'titi@toto.fr', "commandes.voyagesSouscrits.idVoyage" : "123"},{$pull : {"commandes.$.voyagesSouscrits" : {"commandes.voyagesSouscrits.idVoyage" : "123"}}})
うまくいきませんでした!
私は何か間違ったことをしましたが、それを見つけることができません....何か考えはありますか?