Skip to main content

Go SDK quick reference for agents

This page is checked against the Go CRUD and query examples at ekodb-client v0.37.0. The Go module is published separately as github.com/ekoDB/ekodb-client-go; v0.37.0 is the examples repository's baseline, not a Go module version. The pinned example go.mod requires Go client v0.31.1 and replaces it with the workspace checkout. Check the module revision used by the application before adopting a newer example.

Runnable Examples (Check Before Guessing)​

Before writing SDK code, consult the matching runnable example below for exact imports, method signatures and error handling. These links follow the SDK's main branch; compare them with the version installed in your application. Follow the language directory's run instructions and use a disposable deployment when executing examples that write data.

TaskRunnable example
CRUDclient_simple_crud.go
QueryBuilderclient_query_builder.go
Joinsclient_joins.go
Schemasclient_schema.go
TTLclient_document_ttl.go
Transactionsclient_transactions.go
Stored Functionsclient_functions.go
Concurrency / Locks / RateLimitsclient_concurrency_stages.go
Chat / RAGclient_chat_basic.go, rag_conversation_system.go
Searchclient_search.go
WebSocketsclient_websocket_subscribe.go
Admin / Permissionsclient_admin.go

Initialize and query​

This function belongs in an application Go package. The application supplies runtime credentials:

import ekodb "github.com/ekoDB/ekodb-client-go"

func listActive(baseURL, apiKey string) ([]ekodb.Record, error) {
client, err := ekodb.NewClient(baseURL, apiKey)
if err != nil {
return nil, err
}
query := ekodb.NewQueryBuilder().Eq("active", true).Limit(25).Build()
return client.Find("agent_tasks", query)
}

NewClient returns (client, error) and handles token exchange. Do not drop its error or add an async/await layer to Go calls.

Method map​

TaskCall shape
Insertclient.Insert(collection, record)
Findclient.Find(collection, query)
Point readclient.FindByID(collection, id)
Merge updateclient.Update(collection, id, fields)
Deleteclient.Delete(collection, id)
Delete collectionclient.DeleteCollection(collection)
Build filter / pageekodb.NewQueryBuilder().Eq(field, value).Limit(n).Skip(offset).Build()

Database operations return errors; propagate or classify each one. Query builders return the SDK query type. A manually built ekodb.Query uses pointer fields for optional limits (Limit: &limit), not a literal integer in that field.

Values and semantics​

  • ekodb.Record is a map. Use native booleans, slices and nested maps for data. Retain the returned id for point operations.
  • Responses may contain typed envelopes. Use ekodb.ExtractRecord(record) or helpers such as GetStringValue, GetBoolValue, GetIntValue, GetObjectValue and GetArrayValue. Check each helper's return signature: for example GetIntValue returns two values.
  • Insert may return only id; fetch the record if other stored fields are needed. Do not assume every insert result echoes the input.
  • TTL, first-write types, filters, missing resources and Count results are server contracts; read canonical formats. Omitted record-update TTL preserves expiry, and Count replaces the working set with one result record.
  • Keep the HTTP status and server error when handling transactions. Never retry a commit solely on a 409 or infer that every Go method mirrors TypeScript's argument order.

The versioned Go examples include functions, TTL, schemas, joins and transactions. Use the matching example and the application's pinned Go module for those signatures. Use REST if a required method is absent from that installed module.