Я смотрел на другие вопросы, но ни один из тех, что я видел, не хочет изменять поле имен с $regex
в оболочке монго.Мои попытки использовать db.collection.update
с $rename
и $regex
не увенчались успехом.
У меня есть коллекция с такими документами:
{
"_id" : "CWE-693",
"Name" : "Protection Mechanism Failure",
"Description" : "The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.",
"Modes_Of_Introduction" : [
"Architecture and Design",
"Implementation",
"Operation"
],
"Common_Consequences" : [
"Bypass Protection Mechanism"
]
}
Я хочу переименовать всеимен полей (кроме «_id»), чтобы исключить подчеркивания («_»), поэтому документ выглядит следующим образом:
{
"_id" : "CWE-693",
"Name" : "Protection Mechanism Failure",
"Description" : "The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.",
"ModesOfIntroduction" : [
"Architecture and Design",
"Implementation",
"Operation"
],
"CommonConsequences" : [
"Bypass Protection Mechanism"
]
}
Возможно ли это с db.collection.update
, с $rename
и$regex
?Существуют ли другие программные способы монго-оболочки для достижения этой цели?