I need to convert a mongo document in Angular, into an array of key value pairs like shown below. e.g. when a client document is recd, the whole document needs to be converted into an array as shown below.
There is an aggregation option in MongoDb - $objectToArray
{ $objectToArray: { item: "foo", qty: 25 } }
result:
[
{
"k" : "item",
"v" : "foo"
},
{
"k" : "qty",
"v" : 25
}
]
I could not find this in Mongoose documentation? Is it available?
Is there a way to achieve this in Angular when the document is received from Node API?