1 / 1
Jul 2024

Hello,
I have a document to represent a product. The properties of the product is defined as subdocuments because of its dynamic nature. Now, for a specific purpose, have to convert these subdocuments as fields of the document. Please suggest an effective query (MongoDB Atlas) for this purpose.

From this:

{ "name": "Skittles wild berries", "properties": [ { "name": "Batch Number", "value": "123456", }, { "name": "Expiry", "value": "2025-12-31", }, ] }

To this:

{ "name": "Skittles wild berries", "Batch Number": "123456", "Expiry":"2025-12-31", }