Couch DB - Mango Query in an Array of objects;

0

Hello, I'm trying to perform a search on CouchDb using Mango Query. My document follows the following structure:

{
  "_id": "189f69eda6843286bde9e0ee83c36ece",
  "_rev": "1-ce465530345f329d97183a2ec294b8e1",
  "tipoDocumento": "acesso",
  "data_inicio": "2015-09-02 19:16:57.000",
  "data_fim": "2015-09-03 06:16:57.000",
  "perfil": {
    "nome": "toy.shanon",
    "ultimo_acesso": "1992-10-19 21:32:42.000",
    "cliente": {
      "nome": "Hailey Klein",
      "login": "[email protected]"
    }
  },
  "assistiu_acesso": [
    {
      "data_inicio": "2017-12-12 07:49:56.000",
      "data_fim": "2017-12-12 13:49:56.000",
      "duracao_efetiva": "4810",
      "titulo": {
        "tipo": "TIPO NUMERO 10",
        "nome": "Vada Rapids",
        "ano": "2004",
        "classificacao_etaria": "16",
        "titulo_capitulo": {
          "nro_temporada": "12",
          "nro_episodio": "23",
          "duracao": "4245",
          "descricao": "Earum."
        }
      }
    },
    {
      "data_inicio": "2015-08-23 21:13:05.000",
      "data_fim": "2015-08-24 15:13:05.000",
      "duracao_efetiva": "5425",
      "titulo": {
        "tipo": "TIPO NUMERO 19",
        "nome": "Schroeder Isle",
        "ano": "1992",
        "classificacao_etaria": "14",
        "titulo_capitulo": {
          "nro_temporada": "3",
          "nro_episodio": "1",
          "duracao": "5551",
          "descricao": "Hic."
        }
      }
    }
  ]
}

In a query, I want to get some specific fields, and the value of each "effective_time", within watched_access. I was able to get the result I want in the following way:

{
   "selector": {
      "tipoDocumento": "acesso",
      "perfil": {
         "cliente": {
            "login": "[email protected]"
         }
      }
   },
   "fields": [
      "perfil.cliente.nome",
      "perfil.cliente.login",
      "perfil.nome",
      "assistiu_acesso.0.duracao_efetiva",
      "assistiu_acesso.1.duracao_efetiva"
   ]
}

In the case of an array of objects, it stores an array of objects, in which case it is necessary to "iterate" on it in a dynamic way, instead of picking up the position .... that is, I want to get the value of the field "duration_effective" of the number of objects inside the array .. Any tips or suggestions?

    
asked by anonymous 13.04.2018 / 02:41

0 answers