ho questi dati in Mongo:Aggiornare un elemento in sub di sub-array in MongoDB
{
"_id" : ObjectId("505fd43fdbed3dd93f0ae088"),
"categoryName" : "Cat 1",
"services" : [
{
"serviceName" : "Svc 1",
"input" : [
{ "quantity" : 10, "note" : "quantity = 10" },
{ "quantity" : 20, "note" : "quantity = 20" }
]
},
{
"serviceName" : "Svc 2",
"input" : [
{ "quantity" : 30, "note" : "quantity = 30" },
{ "quantity" : 40, "note" : "quantity = 40" }
]
}
]
}
Ora voglio aggiornare la quantità per "Svc 1":
{ "quantity" : 10, "note" : "quantity = 10" }
come:
{"quantity": 100, "note": "changed to 100"}
Come posso fare con Mongo? `
Come ho kno w, l'operatore operativo supporta solo il primo array, qualcuno ha consigliato di usare l'indice di un elemento del sotto-array secondario, ma il problema è che come può sapere quell'indice in fase di esecuzione? (Sto usando il driver C# nativo di MongoDB)
Grazie in anticipo per il vostro aiuto!
Johnny
Ci è una richiesta correlata [SERVER-267] (https://jira.mongodb.org/browse/SERVER-267) (supporto jolly parziale) nel tracker dei problemi di MongoDB. – Stennie
Grazie per il tuo aiuto, Stennie! Attualmente raggruppo l'array di input e output in un'altra raccolta come soluzione alternativa. – Johnny