I have the following structure:
- Collection
- document
- message
- field 1
- field 2
- field 3
The document will start like before, I will need to find the document by searching like:
db.document.find( { "message.field1": "a" } )
and when found, add a another message as an array and will end up like this:
- Collection
- document
- message
- field 1
- field 2
- field 3
- message (new doc)
- field 1
- field 2
- field 3
I'm trying to do:
db.packets.update(
{ $or: [
{ "message.field1": "a" } , { "message.field2": "a" }
]},
{
packet: {
"packet" : {
"field1" : "whatever",
"field2" : "Whatever",
"field3" : "blahblah"
}
}
},
{
upsert: true
} )
But mongo doesn't seem to find the subdocument I'm searching for... is it possible to have multiple arrays? I'm thinking maybe mongodb doesn't allow to have multiple subdocuments with the same name?
Thanks guys,
David