How to assemble an object?

Asked

Viewed 32 times

0

I’d like the key and the value cotação and modalidade of the collection confronto remain in their respective objects whose id is the same in the collection palpites. How can I do that?

[{
    "_id": "59b445edc7e10e11ec8127ec",
    "palpites": [
        {
            "_id": "59b445bcc7e10e11ec8127e8",
            "campeonato": "brasil - série a",
            "casa": "chapecoense",
            "fora": "avai",
            "horario": "2017-08-11T20:00:00.000Z",
            "status": 0,
            "placar": {
                "fora": 0,
                "casa": 1
            }
        },
        {
            "_id": "59b445dfc7e10e11ec8127ea",
            "campeonato": "brasil - série a",
            "casa": "palmeiras",
            "fora": "santos",
            "horario": "2017-08-11T20:00:00.000Z",
            "status": 0,
            "placar": {
                "fora": 0,
                "casa": 1
            }
        }
    ],
    "nome": "wedson",
    "agente": "agente",
    "cotacao": 0,
    "premio": 0,
    "vencedor": 0,
    "tipo": 1,
    "usuario": "59b4459ec7e10e11ec8127e6",
    "horario": "2017-09-09T19:50:05.160Z",
    "confronto": [{
        "confronto_id": "59b445bcc7e10e11ec8127e8",
        "cotacao": 1.5,
        "modalidade": 1
    },{
        "confronto_id": "59b445dfc7e10e11ec8127ea",
        "cotacao": 2.5,
        "modalidade": 2
    }]
}]

1 answer

0

Would that be?

    [{
    "_id": "59b445edc7e10e11ec8127ec",
    "palpites": [
        {
            "_id": "59b445bcc7e10e11ec8127e8",
            "campeonato": "brasil - série a",
            "casa": "chapecoense",
            "fora": "avai",
            "horario": "2017-08-11T20:00:00.000Z",
            "status": 0,
            "placar": {
                "fora": 0,
                "casa": 1
            },
            "confronto": {
                "confronto_id": "59b445bcc7e10e11ec8127e8",
                "cotacao": 1.5,
                "modalidade": 1
            }
        },
        {
            "_id": "59b445dfc7e10e11ec8127ea",
            "campeonato": "brasil - série a",
            "casa": "palmeiras",
            "fora": "santos",
            "horario": "2017-08-11T20:00:00.000Z",
            "status": 0,
            "placar": {
                "fora": 0,
                "casa": 1
            },
            "confronto": {
                "confronto_id": "59b445dfc7e10e11ec8127ea",
                "cotacao": 2.5,
                "modalidade": 2
            }
        }
    ],
    "nome": "wedson",
    "agente": "agente",
    "cotacao": 0,
    "premio": 0,
    "vencedor": 0,
    "tipo": 1,
    "usuario": "59b4459ec7e10e11ec8127e6",
    "horario": "2017-09-09T19:50:05.160Z",
    "confronto": [{
        "confronto_id": "59b445bcc7e10e11ec8127e8",
        "cotacao": 1.5,
        "modalidade": 1
    },{
        "confronto_id": "59b445dfc7e10e11ec8127ea",
        "cotacao": 2.5,
        "modalidade": 2
    }] 
}]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.