Couchbase子文档仅选择所需的字段

时间:2017-02-19 17:26:35

标签: couchbase n1ql

我只需从子文档中选择一个字段。

离。原始文件

{
   "geo" : {
      "lat" : 37.700967,
      "alt" : 5622,
      "lon" : -113.098847
   },
   "tz" : "America/Denver",
   "id" : 3824,
   "type" : "airport",
   "city" : "Cedar City",
   "country" : "United States",
   "icao" : "KCDC",
   "faa" : "CDC",
   "airportname" : "Cedar City Rgnl"
}

我希望它为

{ 
    "geo" : { "alt" : 5622 }, 
    "tz" : "America/Denver", 
    "id" : 3824, 
    "type" : "airport", 
    "city" : "Cedar City", 
    "country" : "United States", 
    "icao" : "KCDC", 
    "faa" : "CDC", 
    "airportname" : "Cedar City Rgnl" 
}

我需要从“geo”子文档中仅选择“alt”字段,但是当我在查询中将其称为geo.alt时,它将返回主文档的字段。我需要保留完整的文档结构。

SELECT airportname, city, country, geo.alt FROM `travel-sample` WHERE type="airport"

有任何建议吗?

0 个答案:

没有答案