Query #
Base method used to send queries to Kuzzle, following the API Documentation.
This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
Arguments #
Query(request *types.KuzzleRequest, options types.QueryOptions, responseChannel chan<- *types.KuzzleResponse)
Argument | Type | Description |
---|---|---|
request | *types.KuzzleRequest | API request options |
options | types.QueryOptions | Additional query options |
responseChannel | chan<- *types.KuzzleResponse | A channel to receive the API response |
request #
Properties required for the Kuzzle API can be set in the KuzzleRequest. The following properties are the most common.
Property | Type | Description |
---|---|---|
Controller | string | Controller name |
Action | string | Action name |
Body | interface{} | Query body for this action |
Index | string | Index name for this action |
Collection | string | Collection name for this action |
Id | string | id for this action |
Volatile | VolatileData | Additional information to send to Kuzzle |
options #
A QueryOptions containing additional query options Theses properties can bet Get/Set. The following properties are the most common.
Property | Type | Description | Default |
---|---|---|---|
Queuable | bool | Make this request queuable or not | true |
responseChannel #
A channel to receive the API response. This channel will receive a KuzzleResponse
Usage #
request := types.KuzzleRequest{
Controller: "document",
Action: "create",
Id: "my-custom-document-id",
Index: "nyc-open-data",
Collection: "yellow-taxi",
Body: json.RawMessage("{\"trip_distance\": 4.23, \"passenger_count\": 2}"),
}
options := types.NewQueryOptions()
options.SetRefresh("wait_for")
ch := make(chan *types.KuzzleResponse)
go kuzzle.Query(&request, options, ch)
response := <-ch
if response.Status == 200 {
fmt.Println("Document created")
} else {
fmt.Println(response.Error.Message)
}
Edit this page on Github(opens new window)