У меня есть такой документ.
{
"_id" : "59a82381362a337f2b50afb2",
"title" : "First Page here",
"slug" : "first-page-here",
"header_image" : null,
"status" : "active",
"seo" : {
"meta_title" : "First page",
"meta_content" : "Firts page for Tareto",
"meta_description" : "Tarento to have a first page"
},
"sections" : [
{
"title" : null,
"position" : "0",
"columns" : [
{
"column_size" : "12",
"column_type" : "Text",
"column_title" : null,
"blocks" : {
"block_id" : "1",
"block_type" : "Text",
"block_title" : null,
"block_contents" : "First page test",
"block_image" : null,
"block_image_width" : null,
"block_image_height" : null,
"block_image_alt_text" : null,
"block_image_align" : null
}
}
]
},
{
"title" : null,
"position" : "1",
"columns" : [
{
"column_size" : "12",
"column_type" : "Accordion",
"column_title" : null,
"blocks" : {
"block_id" : "2",
"block_type" : "Accordion",
"block_title" : null,
"block_contents" : null,
"block_image" : null,
"block_image_width" : null,
"block_image_height" : null,
"block_image_alt_text" : null,
"block_image_align" : null,
"block_child" : [
{
"title" : "Accordion section 1",
"description" : "First page test"
},
{
"title" : "Accordion Section 2 first page",
"description" : "First page"
},
{
"title" : "Accordion Section 3",
"description" : "first page"
}
]
}
}
]
}
],
"website_id" :"59a8227e362a337be32c6392"}
Я хотел бы заменить "первую страницу" в коллекции на "последняя страница". Строка, которую я ищу, может находиться под любым объектом.
Я пробовал этот запрос
db.pages.find({"_id":ObjectId("59a82381362a337f2b50afb2")}).forEach(function(url,k){ url.seo.meta_content=url.seo.meta_content.replace("Firts page for Tareto","First page for Tarento"); db.pages.save(url) });
Запрос на обновление мета-содержимого в seo.
Я хотел бы найти и заменить всю коллекцию. Пожалуйста, помогите мне в этом.