SDK
SDK Golang v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Get #

Gets a document.

Arguments #

Copied to clipboard!
Get(
  index string,
  collection string,
  _id string,
  options types.QueryOptions) (json.RawMessage, error)

Argument Type Description
index
string
Index name
collection
string
Collection name
id
string
Document ID
options
types.QueryOptions
A struct containing query options

options #

Additional query options

Option Type
(default)
Description
Queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Return #

Returns a json.RawMessage containing the document.

Name Type Description
_id string Newly created document ID
_version int Version of the document in the persistent data storage
_source object The created document

Usage #

Copied to clipboard!
_, err := kuzzle.Document.Create(
  "nyc-open-data",
  "yellow-taxi",
  "some-id",
  json.RawMessage(`{"capacity": 4}`),
  nil)
response, err := kuzzle.Document.Get("nyc-open-data", "yellow-taxi", "some-id", nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Println(string(response))
  /*
  {
    "_index":"nyc-open-data",
    "_type":"yellow-taxi",
    "_id":"some-id",
    "_version":1,
    "found":true,
    "_source":{
      "capacity":4,
      "_kuzzle_info":{
        "author":"-1",
        "createdAt":1538402859880,
        "updatedAt":null,
        "updater":null,
        "active":true,
        "deletedAt":null
      }
    }
  }
  */
  fmt.Println("Success")
}