2017-10-09 10 views
0

J'ai un Bson avec des documents embarqués suivant la structure ci-dessous. J'aimerais savoir comment obtenir, par exemple, la valeur d'une variable («2014-08-09»: 53,0) ou la valeur d'un inventaire («2014-08-09»: 0,0) à une date précise .Interroger un document incorporé dans MongoDB

{ 
    "_id" : , 
    "last_modified" : "", 
    "client" : "", 
    "credentials" : [], 
    "tags" : [], 
    "variables" : [ 
     { 
      "name" : "sales", 
      "_values" : { 
       "2014-08-09" : 53.0, 
       ... 
      }, 
      "tags" : [], 
      "is_target" : true, 
      "method1" : "", 
      "method2" : "", 
      "vtype" : , 
      "index_type" : 
     }, 
     { 
      "name" : "inventory", 
      "_values" : { 
       "2014-08-09" : 0.0, 
       ... 
      }, 
      "tags" : [], 
      "is_target" : , 
      "method1" : "", 
      "method2" : "", 
      "vtype" : , 
      "index_type" : 
     }, 
     { 
      "name" : "price", 
      "_values" : {}, 
      "tags" : [], 
      "is_target" : , 
      "method2" : "", 
      "method1" : "", 
      "vtype" : , 
      "index_type" : 
     } 
    } 
} 

Répondre