Sub-Document Operations | Couchbase Docs (original) (raw)

While full-document retrievals retrieve the entire document and full document updates require sending the entire document, Sub-Document retrievals only retrieve relevant parts of a document and Sub-Document updates only require sending the updated portions of a document.

You should use Sub-Document operations when you are modifying only portions of a document, and full-document operations when the contents of a document is to change significantly.

| | The Sub-Document operations described on this page are for Key-Value requests only: they are not related to Sub-Document SQL++ (formerly N1QL) queries.Sub-Document SQL++ queries are explained in the section Querying with SQL++. | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

In order to use Sub-Document operations you need to specify a path indicating the location of the Sub-Document. The path follows Path syntax. Considering the document:

hotel_1368.json

{
  "title": "Ayr (Scotland)",
  "name": "Enterkine House Hotel",
  "address": "by Annbank. Ayrshire",
  "directions": "5 miles off A77, follow B742 to Mossblown then Annbank",
  "phone": "+44 1292 520580",
  "tollfree": null,
  "email": null,
  "fax": null,
  "url": "http://www.enterkine.com",
  "checkin": "2.00pm",
  "checkout": "11am",
  "price": "from £100",
  "geo": {
    "lat": 55.48034590743372,
    "lon": -4.51612114906311,
    "accuracy": "ROOFTOP"
  },
  "type": "hotel",
  "id": 1368,
  "country": "United Kingdom",
  "city": "South Ayrshire",
  "state": null,
  "reviews": [],
  "public_likes": ["Georgette Rutherford V", "Ms. Devante Bruen", "Anderson Schmidt", "Mr. Kareem Harvey", "Tessie Shields", "Floyd Bradtke III", "Maurice McDermott", "Michel Franecki", "Laila Ernser"],
  "vacancy": true,
  "description": "four star country house hotel situated in 350 acres of woodland estate yet only 10 mins from Prestwick ,Ayr and Troon. Award winning food by Paul Moffat and team",
  "alias": null,
  "pets_ok": false,
  "free_breakfast": true,
  "free_internet": false,
  "free_parking": false
}

The paths name, geo.lat and public_likes[0] are all valid paths.