WHAT'S NEW?

Mongoose + Nodejs :: Add data to an array field in Mongodb document

We recently had a requirement where were required to update an array inside the document. Array is a filed inside my document apart from few simple datatypes.

Here is the current document structure




I want to add a JSON to this ARRAY field as shown below.

Once added, the document looks like this




This is how we do it in the code. There are many ways apart from this yet, I found this more readable and more easy to use.

0 comments:

Post a Comment