0

Using the mongo shell I want to be able to migrate my existing schema for my hours property on my collection from this:

sunday: [
    {
      end: '6:30 PM',
      start: '11:00 AM',
    },
],
monday: ...

To this:

sunday: {
  hours: [
    {
      end: '6:30 PM',
      start: '11:00 AM',
    },
  ],
  open: true,
},
  • you could use somethig similar as [this](https://stackoverflow.com/questions/22903849/how-to-flatten-a-subdocument-into-root-level-in-mongodb), but I see that you have more complex data structure, so might not be the most elegant solution, on the other hand you can work with Javascript when handling mongo documents, these documents can be saved into variabled, and manipulated as a plain JS object can. – David Laci Jan 26 '22 at 16:59
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 05 '22 at 18:15

0 Answers0