我有一个看起来像这样的 Mongo Collection
{
"_id": ObjectId("0000000000000123"),
"user_id": NumberLong(000010),
"location": {
"addresses": [{
"number": NumberLong(4410),
"street": "Test Drive",
"county": "New York County",
"city": "New York",
"state": "NY",
"zip": "00001",
"links": [{
"image": "http://www.google.com/test",
"datetime": " 11/24/1952"
}, {
"image": "http://www.google.com/test2",
"datetime": " 11/24/1990"
}
]
}
]
}
}
我需要能够在链接数组中搜索带有 www.google.com 的文档,并能够将其更改为 www.yahoo.com
我尝试了几个版本的 mongo 更新但没有成功
$search_string = new MongoRegex("/www.google.com/i");
$collection->update(
array('location.addresses.links.image' => $search_string),
array('$set' => array('location.addresses.$.links.$.image' => '')),
array("multiple" => true)
);