N
N
Nastya090922019-09-09 16:33:45
JavaScript
Nastya09092, 2019-09-09 16:33:45

How to rename a field on some objects in mongo?

{
  "_id": "1",
  "demands": [
    {
      "dp": {
        "name": "ABCDDD"
      },
      "old_field_name": "some value"
    }
  ]
}
{
  "_id": "2",
  "demands": [
    {
      "dp": {
        "name": "ABCEEE"
      },
      "old_field_name": "some value"
    },
    {
      "dp": {
        "name": "XYZ"
      },
      "field_name": "some value"
    }
  ]
}

There is a similar object structure in mongo.
How to rename field old_field_name to new_field_name in all objects whose dp.name contains "ABC" ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question