skip to Main Content

Mongodb – Mongo aggregation to fetch indexed values from string

Here is the sample document { "pId":12345, "charges": { "key1": "10.0,11.0,12.0,13.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0", "key2": "22.5%,12.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%,22.5%", "key3": "271.95,371.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,271.95,394.45,271.95,394.45", ... } } Charge keys are dynamic. I wanted to fetch the requested index values from charges Ex: input index is (1, 2) the expected…

VIEW QUESTION

MongoDB format data in an array of objects

I have data on a MongoDB collection stored in documents like these: { "_id": "657c54befca2b6a2cdd935ba", "data": { "name": "Bob", "surname": "xxx", "age": "20", }, "header": { "data": "1702646974156", } "_class": "Prova" } { "_id": "657c54befca2b6a2cdd935bb", "data": { "name": "Tom", "surname":…

VIEW QUESTION
Back To Top
Search