Documentation
ΒΆ
Overview ΒΆ
Package ekodb provides a Go client for ekoDB
Package ekodb provides a Go client for ekoDB ΒΆ
Package ekodb provides a Go client for ekoDB ΒΆ
Package ekodb provides a Go client for ekoDB ΒΆ
Package ekodb provides a Go client for ekoDB ΒΆ
Package ekodb provides a Go client for ekoDB
Index ΒΆ
- func BoolPtr(v bool) *bool
- func ExtractRecord(record map[string]interface{}) map[string]interface{}
- func FieldArray(values interface{}) map[string]interface{}
- func FieldBinary(value []byte) map[string]interface{}
- func FieldBinaryBase64(value string) map[string]interface{}
- func FieldBoolean(value bool) map[string]interface{}
- func FieldBytes(value []byte) map[string]interface{}
- func FieldBytesBase64(value string) map[string]interface{}
- func FieldDateTime(value time.Time) map[string]interface{}
- func FieldDateTimeString(value string) map[string]interface{}
- func FieldDecimal(value string) map[string]interface{}
- func FieldDuration(milliseconds int64) map[string]interface{}
- func FieldDurationFromGo(d time.Duration) map[string]interface{}
- func FieldFloat(value float64) map[string]interface{}
- func FieldInteger(value int64) map[string]interface{}
- func FieldNumber(value interface{}) map[string]interface{}
- func FieldObject(value map[string]interface{}) map[string]interface{}
- func FieldSet(values interface{}) map[string]interface{}
- func FieldString(value string) map[string]interface{}
- func FieldUUID(value string) map[string]interface{}
- func FieldVector(values []float64) map[string]interface{}
- func Float32Ptr(v float32) *float32
- func GetArrayValue(field interface{}) []interface{}
- func GetBinaryValue(field interface{}) []byte
- func GetBoolValue(field interface{}) bool
- func GetBytesValue(field interface{}) []byte
- func GetDateTimeValue(field interface{}) *time.Time
- func GetDecimalValue(field interface{}) float64
- func GetDurationValue(field interface{}) time.Duration
- func GetFloatValue(field interface{}) float64
- func GetIntValue(field interface{}) (int, bool)
- func GetObjectValue(field interface{}) map[string]interface{}
- func GetSetValue(field interface{}) []interface{}
- func GetStringValue(field interface{}) string
- func GetUUIDValue(field interface{}) string
- func GetValue(field interface{}) interface{}
- func GetValues(record map[string]interface{}, fields []string) map[string]interface{}
- func GetVectorValue(field interface{}) []float64
- func Int32Ptr(v int32) *int32
- func IntPtr(v int) *int
- func Parameter(name string) map[string]interface{}
- func StringPtr(v string) *string
- type BatchDeleteOptions
- type BatchInsertOptions
- type BatchUpdateOptions
- type CachedSchema
- type ChatMessage
- type ChatMessageRequest
- type ChatModels
- type ChatRequest
- type ChatResponse
- type ChatSendOptions
- type ChatSession
- type ChatSessionResponse
- type ChatStreamEvent
- type Client
- func (c *Client) AgentCreate(data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) AgentDelete(id string) error
- func (c *Client) AgentGet(id string) (map[string]interface{}, error)
- func (c *Client) AgentGetByName(name string) (map[string]interface{}, error)
- func (c *Client) AgentList() (map[string]interface{}, error)
- func (c *Client) AgentUpdate(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) AgentsByDeployment(deploymentId string) (map[string]interface{}, error)
- func (c *Client) BatchDelete(collection string, ids []string, opts ...BatchDeleteOptions) (int, error)
- func (c *Client) BatchInsert(collection string, records []Record, opts ...BatchInsertOptions) ([]Record, error)
- func (c *Client) BatchUpdate(collection string, updates map[string]Record, opts ...BatchUpdateOptions) ([]Record, error)
- func (c *Client) BeginTransaction(isolationLevel string) (string, error)
- func (c *Client) BranchChatSession(request CreateChatSessionRequest) (*ChatResponse, error)
- func (c *Client) CallFunction(labelOrID string, params map[string]interface{}) (*FunctionResult, error)
- func (c *Client) ChatMessage(sessionID string, request ChatMessageRequest) (*ChatResponse, error)
- func (c *Client) ChatMessageStream(ctx context.Context, sessionID string, request ChatMessageRequest) (chan ChatStreamEvent, error)
- func (c *Client) ClearTokenCache()
- func (c *Client) CollectionExists(collection string) (bool, error)
- func (c *Client) CommitTransaction(transactionID string) error
- func (c *Client) CompactChat(sessionID string, keepRecent *int) (*CompactChatResponse, error)
- func (c *Client) ConnectWS() (*WebSocketClient, error)
- func (c *Client) CountDocuments(collection string) (int, error)
- func (c *Client) CreateChatSession(request CreateChatSessionRequest) (*ChatResponse, error)
- func (c *Client) CreateCollection(collection string, schema Schema) error
- func (c *Client) CreateSavepoint(transactionID, name string) error
- func (c *Client) CreateSchedule(data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) Delete(collection, id string, opts ...DeleteOptions) error
- func (c *Client) DeleteChatMessage(sessionID, messageID string) error
- func (c *Client) DeleteChatSession(sessionID string) error
- func (c *Client) DeleteCollection(collection string) error
- func (c *Client) DeleteFunction(id string) error
- func (c *Client) DeleteSchedule(id string) error
- func (c *Client) DeleteUserFunction(label string) error
- func (c *Client) DistinctValues(collection, field string, query DistinctValuesQuery) (*DistinctValuesResponse, error)
- func (c *Client) Embed(text, model string) ([]float64, error)
- func (c *Client) EmbedBatch(texts []string, model string) ([][]float64, error)
- func (c *Client) EnableSchemaCache(ttl time.Duration, maxEntries int)
- func (c *Client) ExecuteTool(toolName string, params map[string]interface{}, sessionID string) (map[string]interface{}, error)
- func (c *Client) Exists(collection, id string) (bool, error)
- func (c *Client) ExtractRecordID(collection string, record map[string]interface{}) string
- func (c *Client) Find(collection string, query interface{}, opts ...FindOptions) ([]Record, error)
- func (c *Client) FindAll(collection string, limit int) ([]Record, error)
- func (c *Client) FindByID(collection, id string, opts ...FindByIDOptions) (Record, error)
- func (c *Client) FindByIDWithProjection(collection, id string, selectFields, excludeFields []string) (Record, error)
- func (c *Client) FindOne(collection, field string, value interface{}) (Record, error)
- func (c *Client) GetChatMessage(sessionID, messageID string) (Record, error)
- func (c *Client) GetChatModel(providerName string) ([]string, error)
- func (c *Client) GetChatModels() (*ChatModels, error)
- func (c *Client) GetChatSession(sessionID string) (*ChatSessionResponse, error)
- func (c *Client) GetChatSessionMessages(sessionID string, query *GetMessagesQuery) (*GetMessagesResponse, error)
- func (c *Client) GetChatTools() ([]map[string]interface{}, error)
- func (c *Client) GetCollection(collection string) (*CollectionMetadata, error)
- func (c *Client) GetFunction(id string) (*UserFunction, error)
- func (c *Client) GetRateLimitInfo() *RateLimitInfo
- func (c *Client) GetSchedule(id string) (map[string]interface{}, error)
- func (c *Client) GetSchema(collection string) (*Schema, error)
- func (c *Client) GetSchemaCache() *SchemaCache
- func (c *Client) GetTransactionStatus(transactionID string) (map[string]interface{}, error)
- func (c *Client) GetUserFunction(label string) (*UserFunction, error)
- func (c *Client) GoalApprove(id string) (map[string]interface{}, error)
- func (c *Client) GoalComplete(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalCreate(data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalDelete(id string) error
- func (c *Client) GoalGet(id string) (map[string]interface{}, error)
- func (c *Client) GoalList() (map[string]interface{}, error)
- func (c *Client) GoalReject(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalSearch(query string) (map[string]interface{}, error)
- func (c *Client) GoalStepComplete(id string, stepIndex int, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalStepFail(id string, stepIndex int, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalStepStart(id string, stepIndex int) (map[string]interface{}, error)
- func (c *Client) GoalTemplateCreate(data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalTemplateDelete(id string) error
- func (c *Client) GoalTemplateGet(id string) (map[string]interface{}, error)
- func (c *Client) GoalTemplateList() (map[string]interface{}, error)
- func (c *Client) GoalTemplateUpdate(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) GoalUpdate(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) Health() error
- func (c *Client) HealthStatus() (*HealthStatus, error)
- func (c *Client) HybridSearch(collection, queryText string, queryVector []float64, limit int) ([]Record, error)
- func (c *Client) Insert(collection string, record Record, opts ...InsertOptions) (Record, error)
- func (c *Client) IsNearRateLimit() bool
- func (c *Client) KVBatchDelete(keys []string) ([][]interface{}, error)
- func (c *Client) KVBatchGet(keys []string) ([]map[string]interface{}, error)
- func (c *Client) KVBatchSet(entries []map[string]interface{}) ([][]interface{}, error)
- func (c *Client) KVClear() error
- func (c *Client) KVDelete(key string) error
- func (c *Client) KVExists(key string) (bool, error)
- func (c *Client) KVFind(pattern string, includeExpired bool) ([]map[string]interface{}, error)
- func (c *Client) KVGet(key string) (interface{}, error)
- func (c *Client) KVGetLinks(key string) (map[string]interface{}, error)
- func (c *Client) KVLink(key, collection, documentId string) (map[string]interface{}, error)
- func (c *Client) KVQuery(pattern string, includeExpired bool) ([]map[string]interface{}, error)
- func (c *Client) KVSet(key string, value interface{}) error
- func (c *Client) KVUnlink(key, collection, documentId string) (map[string]interface{}, error)
- func (c *Client) ListChatSessions(query *ListSessionsQuery) (*ListSessionsResponse, error)
- func (c *Client) ListCollections() ([]string, error)
- func (c *Client) ListFunctions(tags []string) ([]UserFunction, error)
- func (c *Client) ListSchedules() (map[string]interface{}, error)
- func (c *Client) ListUserCollections() ([]string, error)
- func (c *Client) ListUserFunctions(tags []string) ([]UserFunction, error)
- func (c *Client) MergeChatSessions(request MergeSessionsRequest) (*ChatSessionResponse, error)
- func (c *Client) Paginate(collection string, page, pageSize int) ([]Record, error)
- func (c *Client) PauseSchedule(id string) (map[string]interface{}, error)
- func (c *Client) RawCompletion(request RawCompletionRequest) (*RawCompletionResponse, error)
- func (c *Client) RawCompletionStream(request RawCompletionRequest) (*RawCompletionResponse, error)
- func (c *Client) RawCompletionStreamWithProgress(request RawCompletionRequest, onToken func(string)) (*RawCompletionResponse, error)
- func (c *Client) RefreshToken() (string, error)
- func (c *Client) RegenerateChatMessage(sessionID, messageID string) (*ChatResponse, error)
- func (c *Client) ReleaseSavepoint(transactionID, name string) error
- func (c *Client) RestoreCollection(collection string) (int, error)
- func (c *Client) RestoreRecord(collection, id string) error
- func (c *Client) ResumeSchedule(id string) (map[string]interface{}, error)
- func (c *Client) RollbackToSavepoint(transactionID, name string) error
- func (c *Client) RollbackTransaction(transactionID string) error
- func (c *Client) SaveFunction(function UserFunction) (string, error)
- func (c *Client) SaveUserFunction(userFunction UserFunction) (string, error)
- func (c *Client) Search(collection string, searchQuery SearchQuery) (*SearchResponse, error)
- func (c *Client) SubmitChatToolKeepalive(sessionID, callID string) error
- func (c *Client) SubmitChatToolResult(sessionID, callID string, success bool, result interface{}, errMsg string) error
- func (c *Client) SubscribeSSE(ctx context.Context, collection string, opts *SubscribeSSEOptions) (*SSESubscription, error)
- func (c *Client) TaskCreate(data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) TaskDelete(id string) error
- func (c *Client) TaskDue(now string) (map[string]interface{}, error)
- func (c *Client) TaskFail(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) TaskGet(id string) (map[string]interface{}, error)
- func (c *Client) TaskList() (map[string]interface{}, error)
- func (c *Client) TaskPause(id string) (map[string]interface{}, error)
- func (c *Client) TaskResume(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) TaskStart(id string) (map[string]interface{}, error)
- func (c *Client) TaskSucceed(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) TaskUpdate(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) TextSearch(collection, queryText string, limit int) ([]Record, error)
- func (c *Client) ToggleForgottenMessage(sessionID, messageID string, forgotten bool) error
- func (c *Client) Update(collection, id string, record Record, opts ...UpdateOptions) (Record, error)
- func (c *Client) UpdateChatMessage(sessionID, messageID, content string) error
- func (c *Client) UpdateChatSession(sessionID string, request UpdateSessionRequest) (*ChatSessionResponse, error)
- func (c *Client) UpdateFunction(id string, function UserFunction) error
- func (c *Client) UpdateSchedule(id string, data map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) UpdateUserFunction(label string, userFunction UserFunction) error
- func (c *Client) UpdateWithAction(collection, id, action, field string, value interface{}) (Record, error)
- func (c *Client) UpdateWithActionSequence(collection, id string, actions [][3]interface{}) (Record, error)
- func (c *Client) Upsert(collection, id string, record Record, opts ...UpsertOptions) (Record, error)
- func (c *Client) WebSocket(wsURL string) (*WebSocketClient, error)
- type ClientConfig
- type ClientToolDef
- type ClientToolDefinition
- type CollectionConfig
- type CollectionMetadata
- type CompactChatRequest
- type CompactChatResponse
- type CreateChatSessionRequest
- type DeleteOptions
- type DistanceMetric
- type DistinctValuesQuery
- type DistinctValuesResponse
- type EmailSendOptions
- type EmbedRequest
- type EmbedResponse
- type ExecuteToolRequest
- type ExecuteToolResult
- type FieldTypeSchema
- type FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) BTreeIndex() *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) Build() FieldTypeSchema
- func (fb *FieldTypeSchemaBuilder) DefaultValue(value interface{}) *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) Enums(values []interface{}) *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) HashIndex() *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) Pattern(regex string) *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) Range(min, max interface{}) *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) Required() *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) TextIndex(language string) *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) Unique() *FieldTypeSchemaBuilder
- func (fb *FieldTypeSchemaBuilder) VectorIndex(algorithm VectorIndexAlgorithm, metric DistanceMetric, m, efConstruction int) *FieldTypeSchemaBuilder
- type FieldValue
- type FindByIDOptions
- type FindOptions
- type FunctionCondition
- func ConditionAnd(conditions []FunctionCondition) FunctionCondition
- func ConditionCountEquals(count int) FunctionCondition
- func ConditionCountGreaterThan(count int) FunctionCondition
- func ConditionCountLessThan(count int) FunctionCondition
- func ConditionFieldEquals(field string, value interface{}) FunctionCondition
- func ConditionFieldExists(field string) FunctionCondition
- func ConditionHasRecords() FunctionCondition
- func ConditionNot(condition FunctionCondition) FunctionCondition
- func ConditionOr(conditions []FunctionCondition) FunctionCondition
- type FunctionResult
- type FunctionStageConfig
- func StageAesDecrypt(ciphertextField, key, outputField, keyEncoding string) FunctionStageConfig
- func StageAesEncrypt(plaintext, key, outputField, keyEncoding string) FunctionStageConfig
- func StageBase64Decode(input, outputField string, urlSafe *bool) FunctionStageConfig
- func StageBase64Encode(input, outputField string, urlSafe *bool) FunctionStageConfig
- func StageBatchDelete(collection string, ids []string, bypassRipple bool) FunctionStageConfig
- func StageBatchInsert(collection string, records []map[string]interface{}, bypassRipple bool) FunctionStageConfig
- func StageBcryptHash(plain, outputField string, cost *int) FunctionStageConfig
- func StageBcryptVerify(plain, hashField, outputField string) FunctionStageConfig
- func StageCallFunction(functionLabel string, params map[string]interface{}) FunctionStageConfig
- func StageChat(messages []ChatMessage, model *string, temperature *float64) FunctionStageConfig
- func StageCount(outputField string) FunctionStageConfig
- func StageCreateSavepoint(name string) FunctionStageConfig
- func StageDelete(collection string, filter interface{}, bypassRipple bool) FunctionStageConfig
- func StageDeleteById(collection string, recordId string, bypassRipple bool) FunctionStageConfig
- func StageEmailSend(to, subject, body, from, apiKey string, opts *EmailSendOptions) FunctionStageConfig
- func StageEmbed(texts interface{}, model *string) FunctionStageConfig
- func StageFindAll(collection string) FunctionStageConfig
- func StageFindById(collection string, recordId string) FunctionStageConfig
- func StageFindOne(collection string, key string, value interface{}) FunctionStageConfig
- func StageFindOneAndUpdate(collection string, recordId string, updates map[string]interface{}, ...) FunctionStageConfig
- func StageForEach(functions []FunctionStageConfig) FunctionStageConfig
- func StageGroup(by_fields []string, functions []GroupFunctionConfig) FunctionStageConfig
- func StageHexDecode(input, outputField string) FunctionStageConfig
- func StageHexEncode(input, outputField string) FunctionStageConfig
- func StageHmacSign(input, secret, outputField, algorithm, encoding string) FunctionStageConfig
- func StageHmacVerify(input, providedMac, secret, outputField, algorithm, encoding string) FunctionStageConfig
- func StageHttpRequest(url, method string, headers map[string]string, body interface{}) FunctionStageConfig
- func StageHybridSearch(collection string, queryText string, queryVector []float64, ...) FunctionStageConfig
- func StageIdempotencyClaim(key string, ttlSecs uint64, outputField string) FunctionStageConfig
- func StageIf(condition FunctionCondition, thenFunctions []FunctionStageConfig, ...) FunctionStageConfig
- func StageInsert(collection string, record map[string]interface{}, bypassRipple bool, ...) FunctionStageConfig
- func StageJwtSign(claims map[string]interface{}, secret, outputField string, ...) FunctionStageConfig
- func StageJwtVerify(tokenField, secret, outputField, algorithm string) FunctionStageConfig
- func StageKvDelete(key string) FunctionStageConfig
- func StageKvExists(key string, outputField *string) FunctionStageConfig
- func StageKvGet(key string) FunctionStageConfig
- func StageKvQuery(pattern *string, includeExpired bool) FunctionStageConfig
- func StageKvSet(key string, value interface{}, ttl *int64) FunctionStageConfig
- func StageLockAcquire(key string, ttlSecs uint64, outputField string) FunctionStageConfig
- func StageLockRelease(key, token, outputField string) FunctionStageConfig
- func StageParallel(functions []FunctionStageConfig, waitForAll bool) FunctionStageConfig
- func StageProject(fields []string, exclude bool) FunctionStageConfig
- func StageQuery(collection string, filter interface{}, sort []SortFieldConfig, ...) FunctionStageConfig
- func StageRandomToken(bytes int, encoding, outputField string) FunctionStageConfig
- func StageRateLimit(key string, limit, windowSecs uint64, outputField, onExceed string) FunctionStageConfig
- func StageReleaseSavepoint(name string) FunctionStageConfig
- func StageReturn(fields map[string]interface{}, statusCode int) FunctionStageConfig
- func StageRollbackToSavepoint(name string) FunctionStageConfig
- func StageSWR(cacheKey string, ttl interface{}, url string, method string, ...) FunctionStageConfig
- func StageSleep(durationMs interface{}) FunctionStageConfig
- func StageSlugify(input, outputField string) FunctionStageConfig
- func StageTextSearch(collection string, queryText string, options map[string]interface{}) FunctionStageConfig
- func StageTotpGenerate(secret, outputField string, opts *TotpOptions) FunctionStageConfig
- func StageTotpVerify(code, secret, outputField string, opts *TotpOptions) FunctionStageConfig
- func StageTryCatch(tryFunctions, catchFunctions []FunctionStageConfig, outputErrorField string) FunctionStageConfig
- func StageUpdate(collection string, filter interface{}, updates map[string]interface{}, ...) FunctionStageConfig
- func StageUpdateById(collection string, recordId string, updates map[string]interface{}, ...) FunctionStageConfig
- func StageUpdateWithAction(collection string, recordId string, action string, field string, ...) FunctionStageConfig
- func StageUuidGenerate(outputField string) FunctionStageConfig
- func StageValidate(schema map[string]interface{}, dataField string, onError []FunctionStageConfig) FunctionStageConfig
- func StageVectorSearch(collection string, queryVector []float64, limit *int, threshold *float64) FunctionStageConfig
- type FunctionStats
- type GetMessagesQuery
- type GetMessagesResponse
- type GroupFunctionConfig
- type GroupFunctionOp
- type HTTPError
- type HealthState
- type HealthStatus
- type IndexConfig
- type InsertOptions
- type JoinConfig
- type ListSessionsQuery
- type ListSessionsResponse
- type MergeSessionsRequest
- type MergeStrategy
- type MutationNotification
- type ParameterDefinition
- type Query
- type QueryBuilder
- func (qb *QueryBuilder) And(conditions []map[string]interface{}) *QueryBuilder
- func (qb *QueryBuilder) Build() map[string]interface{}
- func (qb *QueryBuilder) BuildJSON() ([]byte, error)
- func (qb *QueryBuilder) BypassCache(bypass bool) *QueryBuilder
- func (qb *QueryBuilder) BypassRipple(bypass bool) *QueryBuilder
- func (qb *QueryBuilder) Contains(field string, substring string) *QueryBuilder
- func (qb *QueryBuilder) EndsWith(field string, suffix string) *QueryBuilder
- func (qb *QueryBuilder) Eq(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) ExcludeFields(fields ...string) *QueryBuilder
- func (qb *QueryBuilder) Gt(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) Gte(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) In(field string, values []interface{}) *QueryBuilder
- func (qb *QueryBuilder) Join(joinConfig map[string]interface{}) *QueryBuilder
- func (qb *QueryBuilder) Limit(limit int) *QueryBuilder
- func (qb *QueryBuilder) Lt(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) Lte(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) Ne(field string, value interface{}) *QueryBuilder
- func (qb *QueryBuilder) Nin(field string, values []interface{}) *QueryBuilder
- func (qb *QueryBuilder) Not(condition map[string]interface{}) *QueryBuilder
- func (qb *QueryBuilder) Or(conditions []map[string]interface{}) *QueryBuilder
- func (qb *QueryBuilder) Page(page, pageSize int) *QueryBuilder
- func (qb *QueryBuilder) SelectFields(fields ...string) *QueryBuilder
- func (qb *QueryBuilder) Skip(skip int) *QueryBuilder
- func (qb *QueryBuilder) SortAscending(field string) *QueryBuilder
- func (qb *QueryBuilder) SortDescending(field string) *QueryBuilder
- func (qb *QueryBuilder) StartsWith(field string, prefix string) *QueryBuilder
- type QueryOptions
- type RateLimitError
- type RateLimitInfo
- type RawCompletionRequest
- type RawCompletionResponse
- type Record
- type SSESubscription
- type Schema
- type SchemaBuilder
- type SchemaCache
- func (sc *SchemaCache) ExtractRecordID(collection string, record map[string]interface{}) string
- func (sc *SchemaCache) Get(collection string) *CachedSchema
- func (sc *SchemaCache) GetAlias(collection string) string
- func (sc *SchemaCache) HandleSchemaChanged(collection string, version uint64, primaryKeyAlias string)
- func (sc *SchemaCache) Insert(collection, primaryKeyAlias string, version uint64)
- func (sc *SchemaCache) Invalidate(collection string)
- func (sc *SchemaCache) InvalidateAll()
- func (sc *SchemaCache) IsEnabled() bool
- func (sc *SchemaCache) Len() int
- func (sc *SchemaCache) SetEnabled(enabled bool)
- type SchemaCacheConfig
- type SearchQuery
- type SearchQueryBuilder
- func (sb *SearchQueryBuilder) BoostExact(enabled bool) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Build() SearchQuery
- func (sb *SearchQueryBuilder) BypassCache(bypass bool) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) BypassRipple(bypass bool) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) CaseSensitive(enabled bool) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) EnableStemming(enabled bool) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) ExcludeFields(fields []string) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Fields(fields string) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Filters(filter interface{}) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Fuzzy(enabled bool) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Language(language string) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Limit(limit int) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) MaxEditDistance(distance int) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) MinScore(score float64) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) SelectFields(fields []string) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) TextWeight(weight float64) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Vector(vector []float64) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) VectorField(field string) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) VectorK(k int) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) VectorMetric(metric string) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) VectorThreshold(threshold float64) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) VectorWeight(weight float64) *SearchQueryBuilder
- func (sb *SearchQueryBuilder) Weights(weights string) *SearchQueryBuilder
- type SearchResponse
- type SearchResult
- type SerializationFormat
- type SortFieldConfig
- type SortOrder
- type StageStats
- type SubscribeOptions
- type SubscribeSSEOptions
- type TokenUsage
- type ToolChoice
- type ToolConfig
- type TotpOptions
- type UpdateAction
- type UpdateOptions
- type UpdateSessionRequest
- type UpdateWithActionBody
- type UpsertOptions
- type UserFunction
- type VectorIndexAlgorithm
- type WebSocketClient
- func (ws *WebSocketClient) BatchDelete(collection string, ids []string, bypassRipple ...bool) error
- func (ws *WebSocketClient) BatchInsert(collection string, records []map[string]interface{}, bypassRipple ...bool) (json.RawMessage, error)
- func (ws *WebSocketClient) BatchUpdate(collection string, updates [][2]interface{}, bypassRipple ...bool) (json.RawMessage, error)
- func (ws *WebSocketClient) CancelChat(chatID string) error
- func (ws *WebSocketClient) ChatSend(chatID, message string, opts ...ChatSendOptions) (<-chan ChatStreamEvent, error)
- func (ws *WebSocketClient) Close() error
- func (ws *WebSocketClient) CreateCollection(name string, schema ...interface{}) error
- func (ws *WebSocketClient) Delete(collection, id string, bypassRipple ...bool) error
- func (ws *WebSocketClient) DeleteCollection(name string) error
- func (ws *WebSocketClient) DistinctValues(collection, field string, filter ...interface{}) (json.RawMessage, error)
- func (ws *WebSocketClient) FindAll(collection string) ([]Record, error)
- func (ws *WebSocketClient) FindByID(collection, id string) (json.RawMessage, error)
- func (ws *WebSocketClient) Insert(collection string, record map[string]interface{}, bypassRipple ...bool) (json.RawMessage, error)
- func (ws *WebSocketClient) ListCollections() ([]string, error)
- func (ws *WebSocketClient) Query(collection string, opts ...QueryOptions) (json.RawMessage, error)
- func (ws *WebSocketClient) RawCompletion(request RawCompletionRequest) (*RawCompletionResponse, error)
- func (ws *WebSocketClient) RegisterClientTools(chatID string, tools []ClientToolDefinition) error
- func (ws *WebSocketClient) SendToolResult(chatID, callID string, success bool, result interface{}, errMsg string) error
- func (ws *WebSocketClient) SetSchemaCache(cache *SchemaCache)
- func (ws *WebSocketClient) Subscribe(collection string, opts ...SubscribeOptions) (<-chan MutationNotification, error)
- func (ws *WebSocketClient) TextSearch(collection, query string, fields []string, limit int) (json.RawMessage, error)
- func (ws *WebSocketClient) Unsubscribe(collection string)
- func (ws *WebSocketClient) Update(collection, id string, record map[string]interface{}, bypassRipple ...bool) (json.RawMessage, error)
- func (ws *WebSocketClient) UpdateWithAction(collection, id, action, field string, value ...interface{}) (json.RawMessage, error)
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func ExtractRecord ΒΆ added in v0.6.1
ExtractRecord transforms an entire record by extracting all field values. Preserves the 'id' field and extracts values from all other fields.
Example:
user, _ := client.FindByID("users", userID)
plainUser := ExtractRecord(user)
// plainUser is now map[string]interface{} with plain values
func FieldArray ΒΆ added in v0.7.0
func FieldArray(values interface{}) map[string]interface{}
FieldArray creates an Array field value
func FieldBinary ΒΆ added in v0.7.0
FieldBinary creates a Binary field value from bytes
func FieldBinaryBase64 ΒΆ added in v0.7.0
FieldBinaryBase64 creates a Binary field value from a base64 string
func FieldBoolean ΒΆ added in v0.7.0
FieldBoolean creates a Boolean field value (explicit wrapping)
func FieldBytes ΒΆ added in v0.7.0
FieldBytes creates a Bytes field value from bytes
func FieldBytesBase64 ΒΆ added in v0.7.0
FieldBytesBase64 creates a Bytes field value from a base64 string
func FieldDateTime ΒΆ added in v0.7.0
FieldDateTime creates a DateTime field value
func FieldDateTimeString ΒΆ added in v0.7.0
FieldDateTimeString creates a DateTime field value from an RFC3339 string
func FieldDecimal ΒΆ added in v0.7.0
FieldDecimal creates a Decimal field value for precise numeric values
func FieldDuration ΒΆ added in v0.7.0
FieldDuration creates a Duration field value
func FieldDurationFromGo ΒΆ added in v0.7.0
FieldDurationFromGo creates a Duration field value from a Go time.Duration
func FieldFloat ΒΆ added in v0.7.0
FieldFloat creates a Float field value (explicit wrapping)
func FieldInteger ΒΆ added in v0.7.0
FieldInteger creates an Integer field value (explicit wrapping)
func FieldNumber ΒΆ added in v0.7.0
func FieldNumber(value interface{}) map[string]interface{}
FieldNumber creates a Number field value (flexible numeric type)
func FieldObject ΒΆ added in v0.7.0
FieldObject creates an Object field value
func FieldSet ΒΆ added in v0.7.0
func FieldSet(values interface{}) map[string]interface{}
FieldSet creates a Set field value (unique elements)
func FieldString ΒΆ added in v0.7.0
FieldString creates a String field value (explicit wrapping)
func FieldVector ΒΆ added in v0.7.0
FieldVector creates a Vector field value (for embeddings/similarity search)
func Float32Ptr ΒΆ added in v0.12.0
Float32Ptr returns a pointer to a float32 value
func GetArrayValue ΒΆ added in v0.6.1
func GetArrayValue(field interface{}) []interface{}
GetArrayValue extracts a []interface{} from an ekoDB Array field
func GetBinaryValue ΒΆ added in v0.6.1
func GetBinaryValue(field interface{}) []byte
GetBinaryValue extracts a []byte from an ekoDB Binary field.
This function is a thin wrapper around GetBytesValue and is currently functionally identical to it. ekoDB may expose both "Binary" and "Bytes" field types in schemas, but in this client implementation they are represented and decoded in the same way (as []byte).
Having both GetBinaryValue and GetBytesValue allows callers to choose the helper that best matches their logical schema (e.g., using GetBinaryValue for fields declared as "Binary" in ekoDB), while keeping a single shared implementation for the actual conversion logic.
func GetBoolValue ΒΆ added in v0.6.1
func GetBoolValue(field interface{}) bool
GetBoolValue extracts a bool value from an ekoDB field.
Accepts: bool, string ("true"/"false"/"1"/"0"/"yes"/"no"), int/int64/float64 (non-zero = true).
func GetBytesValue ΒΆ added in v0.6.1
func GetBytesValue(field interface{}) []byte
GetBytesValue extracts a []byte from an ekoDB Bytes field. The underlying field value may be:
- []byte: returned as-is
- []interface{}: each element must be a numeric value (typically float64) in the range [0, 255], which is converted to a byte. If any element is not numeric or is out of range, the function returns nil.
- string: interpreted as a base64-encoded representation of the bytes and decoded using base64.StdEncoding. If decoding fails, the function returns nil.
For any other type or conversion error, GetBytesValue returns nil. Note: Returning nil can mean either a nil field or a conversion error.
func GetDateTimeValue ΒΆ added in v0.6.1
GetDateTimeValue extracts a time.Time value from an ekoDB DateTime field. Supports time.Time values directly and RFC3339-formatted strings. Returns nil if the field is not a datetime or if string parsing fails.
func GetDecimalValue ΒΆ added in v0.6.1
func GetDecimalValue(field interface{}) float64
GetDecimalValue extracts a float64 from an ekoDB Decimal field. Accepts underlying values of type float64, int, int64, or a string containing a decimal representation. If conversion fails, it returns 0.0. This function extends GetFloatValue by adding support for string parsing.
func GetDurationValue ΒΆ added in v0.6.1
GetDurationValue extracts a time.Duration from an ekoDB Duration field. It accepts the following underlying value formats:
- time.Duration: returned as-is.
- int64: interpreted as a time.Duration value in nanoseconds.
- float64: interpreted as a duration in nanoseconds after truncation to int64. Warning: Fractional nanoseconds are truncated (e.g., 1.5 becomes 1 nanosecond). Large float64 values may overflow when converted to int64.
- map[string]interface{} with "secs" and "nanos" float64 fields: {"secs": <seconds>, "nanos": <nanoseconds>} Both secs and nanos are truncated from float64 to int64, losing any fractional components (e.g., 1.5 seconds becomes 1 second). This is converted to secs*time.Second + nanos*time.Nanosecond.
Note: This function returns 0 for both an actual zero duration and invalid/malformed duration objects. Callers cannot distinguish between these cases. If the source of duration data is untrusted or may be corrupted, consider validating the structure before calling this function, or checking the raw field value first.
For any unsupported or invalid format, it returns 0.
func GetFloatValue ΒΆ added in v0.6.1
func GetFloatValue(field interface{}) float64
GetFloatValue extracts a float64 value from an ekoDB field.
Accepts: float32, float64, int, int8-64, uint8-64, json.Number, numeric strings.
func GetIntValue ΒΆ added in v0.6.1
GetIntValue extracts an int value from an ekoDB field. It returns the extracted int and a boolean indicating whether the conversion succeeded.
Accepts: int, int8-64, uint8-64, float32, float64, json.Number, numeric strings. float64 values are truncated (e.g., 3.9 becomes 3).
func GetObjectValue ΒΆ added in v0.6.1
func GetObjectValue(field interface{}) map[string]interface{}
GetObjectValue extracts a map[string]interface{} from an ekoDB Object field
func GetSetValue ΒΆ added in v0.6.1
func GetSetValue(field interface{}) []interface{}
GetSetValue extracts a []interface{} from an ekoDB Set field.
This function is intentionally identical to GetArrayValue and does not validate or enforce element uniqueness. ekoDB enforces set semantics (uniqueness) on the server side, so data retrieved directly from ekoDB is expected to already be unique. If the source of the data is untrusted, manually constructed, or may be corrupted, callers should not rely on this guarantee and should perform their own uniqueness validation or deduplication if required.
func GetStringValue ΒΆ added in v0.6.1
func GetStringValue(field interface{}) string
GetStringValue extracts a string value from an ekoDB field. Returns the unwrapped string value, or empty string if not convertible.
func GetUUIDValue ΒΆ added in v0.6.1
func GetUUIDValue(field interface{}) string
GetUUIDValue extracts a string UUID from an ekoDB UUID field
func GetValue ΒΆ added in v0.6.1
func GetValue(field interface{}) interface{}
GetValue extracts the value from an ekoDB field object. ekoDB returns fields as {"type": "String", "value": "..."} objects. This helper safely extracts the value or returns the input if it's not a field object.
Example:
user, _ := client.FindByID("users", userID)
email := GetStringValue(user["email"])
age := GetIntValue(user["age"])
func GetValues ΒΆ added in v0.6.1
GetValues extracts values from multiple fields in a record. Useful for processing entire records returned from ekoDB.
Example:
user, _ := client.FindByID("users", userID)
values := GetValues(user, []string{"email", "first_name", "status"})
email := GetStringValue(values["email"])
func GetVectorValue ΒΆ added in v0.6.1
func GetVectorValue(field interface{}) []float64
GetVectorValue extracts a []float64 from an ekoDB Vector field. Returns nil if any element cannot be converted to float64 to ensure vector dimension integrity. Note: Returning nil can mean either a nil field or a conversion error, which is important for vector operations where dimension integrity is critical.
func Parameter ΒΆ added in v0.17.0
Parameter returns the structural placeholder `{"type": "Parameter", "name": name}` that ekoDB's `resolve_json_parameters` recognizes inside Insert.record, Update.updates, UpdateById.updates, FindOneAndUpdate.updates, BatchInsert.records, and any query filter expression value.
At function-call time, ekoDB replaces the placeholder with the actual parameter value, preserving the native FieldType (Binary, DateTime, UUID, Decimal, Duration, Number, Set, Vector) via the `{type,value}` wrapped form. Safe to use for any type β scalars and containers alike.
This is the structural alternative to the text-level `"{{name}}"` placeholder; both are accepted by the server. Prefer structural when the parameter is a whole-object record or a value whose type would be lost on a raw-JSON round-trip.
Example β items_create function:
StageInsert("items", Parameter("record"), false, nil)
Example β items_update function:
StageUpdateById("items", "{{id}}", Parameter("updates"), false, nil)
Types ΒΆ
type BatchDeleteOptions ΒΆ added in v0.8.0
BatchDeleteOptions contains optional parameters for BatchDelete
type BatchInsertOptions ΒΆ added in v0.8.0
BatchInsertOptions contains optional parameters for BatchInsert
type BatchUpdateOptions ΒΆ added in v0.8.0
BatchUpdateOptions contains optional parameters for BatchUpdate
type CachedSchema ΒΆ added in v0.15.1
CachedSchema holds cached schema metadata for a collection.
type ChatMessage ΒΆ added in v0.4.0
ChatMessage for AI operations
func NewChatMessage ΒΆ added in v0.4.0
func NewChatMessage(role, content string) ChatMessage
NewChatMessage creates a chat message
type ChatMessageRequest ΒΆ
type ChatMessageRequest struct {
Message string `json:"message"`
BypassRipple *bool `json:"bypass_ripple,omitempty"`
ForceSummarize *bool `json:"force_summarize,omitempty"`
MaxIterations *int `json:"max_iterations,omitempty"`
ToolConfig *ToolConfig `json:"tool_config,omitempty"`
LLMModel *string `json:"llm_model,omitempty"`
ClientTools []ClientToolDef `json:"client_tools,omitempty"`
ConfirmTools []string `json:"confirm_tools,omitempty"`
ExcludeTools []string `json:"exclude_tools,omitempty"`
}
ChatMessageRequest represents a request to send a message in an existing session
type ChatModels ΒΆ added in v0.11.0
type ChatModels struct {
OpenAI []string `json:"openai"`
Anthropic []string `json:"anthropic"`
Perplexity []string `json:"perplexity"`
}
ChatModels contains available models for each provider
type ChatRequest ΒΆ
type ChatRequest struct {
Collections []CollectionConfig `json:"collections"`
LLMProvider string `json:"llm_provider"`
LLMModel *string `json:"llm_model,omitempty"`
Message string `json:"message"`
SystemPrompt *string `json:"system_prompt,omitempty"`
}
ChatRequest represents a request to send a chat message
type ChatResponse ΒΆ
type ChatResponse struct {
ChatID string `json:"chat_id"`
MessageID string `json:"message_id"`
Responses []string `json:"responses"`
ContextSnippets []interface{} `json:"context_snippets"`
ExecutionTimeMs int `json:"execution_time_ms"`
TokenUsage *TokenUsage `json:"token_usage,omitempty"`
}
ChatResponse represents a response from a chat operation
type ChatSendOptions ΒΆ added in v0.13.0
type ChatSendOptions struct {
BypassRipple *bool `json:"bypass_ripple,omitempty"`
ClientTools []ClientToolDefinition `json:"client_tools,omitempty"`
MaxIterations *uint32 `json:"max_iterations,omitempty"`
ConfirmTools []string `json:"confirm_tools,omitempty"`
ExcludeTools []string `json:"exclude_tools,omitempty"`
}
ChatSendOptions are optional parameters for ChatSend.
type ChatSession ΒΆ
type ChatSession struct {
ChatID string `json:"chat_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
LLMProvider string `json:"llm_provider"`
LLMModel string `json:"llm_model"`
Collections []CollectionConfig `json:"collections"`
SystemPrompt *string `json:"system_prompt,omitempty"`
AgentID *string `json:"agent_id,omitempty"`
Title *string `json:"title,omitempty"`
MessageCount int `json:"message_count"`
}
ChatSession represents a chat session
type ChatSessionResponse ΒΆ
type ChatSessionResponse struct {
Session Record `json:"session"`
MessageCount int `json:"message_count"`
}
ChatSessionResponse represents a response containing session details
type ChatStreamEvent ΒΆ added in v0.13.0
type ChatStreamEvent struct {
Type string `json:"type"` // "chunk", "end", "toolCall", "error"
Content string `json:"content,omitempty"`
MessageID string `json:"message_id,omitempty"`
TokenUsage json.RawMessage `json:"token_usage,omitempty"`
ToolCallHistory json.RawMessage `json:"tool_call_history,omitempty"`
ExecutionTimeMs uint64 `json:"execution_time_ms,omitempty"`
ContextWindow uint32 `json:"context_window,omitempty"` // Model's context window size in tokens
ChatID string `json:"chat_id,omitempty"`
CallID string `json:"call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Arguments json.RawMessage `json:"arguments,omitempty"`
Error string `json:"error,omitempty"`
}
ChatStreamEvent represents an event from a streaming chat response.
type Client ΒΆ
type Client struct {
// contains filtered or unexported fields
}
Client represents an ekoDB client
func NewClient ΒΆ
NewClient creates a new ekoDB client (legacy signature for backward compatibility)
func NewClientWithConfig ΒΆ
func NewClientWithConfig(config ClientConfig) (*Client, error)
NewClientWithConfig creates a new ekoDB client with configuration
func (*Client) AgentCreate ΒΆ added in v0.14.0
AgentCreate creates a new agent.
func (*Client) AgentDelete ΒΆ added in v0.14.0
AgentDelete deletes an agent by ID.
func (*Client) AgentGetByName ΒΆ added in v0.14.0
AgentGetByName retrieves an agent by name.
func (*Client) AgentUpdate ΒΆ added in v0.14.0
func (c *Client) AgentUpdate(id string, data map[string]interface{}) (map[string]interface{}, error)
AgentUpdate updates an agent by ID.
func (*Client) AgentsByDeployment ΒΆ added in v0.14.0
AgentsByDeployment retrieves agents associated with a deployment ID.
func (*Client) BatchDelete ΒΆ
func (c *Client) BatchDelete(collection string, ids []string, opts ...BatchDeleteOptions) (int, error)
BatchDelete deletes multiple documents
func (*Client) BatchInsert ΒΆ
func (c *Client) BatchInsert(collection string, records []Record, opts ...BatchInsertOptions) ([]Record, error)
BatchInsert inserts multiple documents
func (*Client) BatchUpdate ΒΆ
func (c *Client) BatchUpdate(collection string, updates map[string]Record, opts ...BatchUpdateOptions) ([]Record, error)
BatchUpdate updates multiple documents
func (*Client) BeginTransaction ΒΆ added in v0.7.0
BeginTransaction starts a new transaction on the server with the given isolation level. The isolationLevel parameter must be one of: "READ_UNCOMMITTED", "READ_COMMITTED", "REPEATABLE_READ", or "SERIALIZABLE". It returns the server-assigned transaction ID as a string, or an error if the transaction could not be created.
func (*Client) BranchChatSession ΒΆ
func (c *Client) BranchChatSession(request CreateChatSessionRequest) (*ChatResponse, error)
BranchChatSession branches a chat session
func (*Client) CallFunction ΒΆ added in v0.16.0
func (c *Client) CallFunction(labelOrID string, params map[string]interface{}) (*FunctionResult, error)
CallFunction executes a function by label or ID
func (*Client) ChatMessage ΒΆ
func (c *Client) ChatMessage(sessionID string, request ChatMessageRequest) (*ChatResponse, error)
ChatMessage sends a message in an existing chat session
func (*Client) ChatMessageStream ΒΆ added in v0.14.0
func (c *Client) ChatMessageStream(ctx context.Context, sessionID string, request ChatMessageRequest) (chan ChatStreamEvent, error)
ChatMessageStream sends a message in an existing chat session via SSE streaming. Uses the same ChatStreamEvent type as the WebSocket ChatSend method.
Returns a channel that yields ChatStreamEvent values as they arrive:
- Chunk events carry incremental token text in Content.
- An End event signals completion and includes MessageID, TokenUsage, etc.
- An Error event carries a description string in Error.
The channel is closed when the stream finishes or an error occurs.
Example:
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ch, err := client.ChatMessageStream(ctx, "chat-id", ChatMessageRequest{Message: "Hello"})
if err != nil { log.Fatal(err) }
for event := range ch {
switch event.Type {
case "chunk":
fmt.Print(event.Content)
case "end":
fmt.Printf("\nDone: %s (%d ms)\n", event.MessageID, event.ExecutionTimeMs)
case "error":
fmt.Println("Error:", event.Error)
}
}
func (*Client) ClearTokenCache ΒΆ added in v0.14.0
func (c *Client) ClearTokenCache()
ClearTokenCache clears the cached authentication token, forcing a fresh token to be fetched on the next request.
func (*Client) CollectionExists ΒΆ added in v0.11.0
CollectionExists checks if a collection exists
func (*Client) CommitTransaction ΒΆ added in v0.7.0
CommitTransaction commits a transaction.
Transactions are buffered: statements issued with this transaction ID (via the TransactionId option on Insert/Update/Delete/Find/FindByID/β¦) are staged and applied atomically here. They are invisible to others until commit, and visible to this transaction's own reads (read-your-writes) only when those reads also carry the transaction ID. Commit may fail with an HTTP 409 conflict if a record this transaction read or wrote was changed by another committed transaction β retry the transaction in that case.
func (*Client) CompactChat ΒΆ added in v0.19.0
func (c *Client) CompactChat(sessionID string, keepRecent *int) (*CompactChatResponse, error)
CompactChat compacts a chat session's history on demand, folding older messages into a summary while keeping the most recent ones intact. Calls POST /api/chat/{chat_id}/compact.
keepRecent optionally overrides how many recent messages to keep verbatim; pass nil to use the server default.
func (*Client) ConnectWS ΒΆ added in v0.15.1
func (c *Client) ConnectWS() (*WebSocketClient, error)
ConnectWS creates a WebSocket client by deriving the WS URL from the base URL. Converts httpβws, httpsβwss (path /api/ws is appended during connect).
func (*Client) CountDocuments ΒΆ added in v0.11.0
CountDocuments counts the number of documents in a collection
func (*Client) CreateChatSession ΒΆ
func (c *Client) CreateChatSession(request CreateChatSessionRequest) (*ChatResponse, error)
CreateChatSession creates a new chat session
func (*Client) CreateCollection ΒΆ
CreateCollection creates a collection with schema
func (*Client) CreateSavepoint ΒΆ added in v0.21.0
CreateSavepoint creates a named savepoint within a transaction. A later RollbackToSavepoint discards everything staged after it.
func (*Client) CreateSchedule ΒΆ added in v0.14.0
CreateSchedule creates a new schedule.
func (*Client) Delete ΒΆ
func (c *Client) Delete(collection, id string, opts ...DeleteOptions) error
Delete deletes a document
func (*Client) DeleteChatMessage ΒΆ
DeleteChatMessage deletes a specific message
func (*Client) DeleteChatSession ΒΆ
DeleteChatSession deletes a chat session
func (*Client) DeleteCollection ΒΆ
DeleteCollection deletes a collection
func (*Client) DeleteFunction ΒΆ added in v0.16.0
DeleteFunction deletes a function by ID
func (*Client) DeleteSchedule ΒΆ added in v0.14.0
DeleteSchedule deletes a schedule by ID.
func (*Client) DeleteUserFunction ΒΆ added in v0.11.0
DeleteUserFunction deletes a user function by label
func (*Client) DistinctValues ΒΆ added in v0.13.0
func (c *Client) DistinctValues(collection, field string, query DistinctValuesQuery) (*DistinctValuesResponse, error)
DistinctValues returns all unique values for a field across a collection.
Results are deduplicated and sorted alphabetically by the server. An optional filter restricts which records are considered.
Example β all distinct statuses:
resp, err := client.DistinctValues("orders", "status", DistinctValuesQuery{})
Example β statuses for US orders only:
t := true
resp, err := client.DistinctValues("orders", "status", DistinctValuesQuery{
Filter: map[string]interface{}{
"type": "Condition",
"content": map[string]interface{}{
"field": "region", "operator": "Eq", "value": "us",
},
},
})
func (*Client) Embed ΒΆ added in v0.5.0
Embed generates embeddings for a single text via the /api/embed endpoint
Example:
embedding, err := client.Embed("Hello world", "text-embedding-3-small")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Generated %d dimensions\n", len(embedding))
func (*Client) EmbedBatch ΒΆ added in v0.12.0
EmbedBatch generates embeddings for multiple texts in a single request
Example:
embeddings, err := client.EmbedBatch([]string{"Hello", "World"}, "text-embedding-3-small")
if err != nil {
log.Fatal(err)
}
func (*Client) EnableSchemaCache ΒΆ added in v0.15.1
EnableSchemaCache enables the in-memory schema cache on this client.
func (*Client) ExecuteTool ΒΆ added in v0.15.0
func (c *Client) ExecuteTool(toolName string, params map[string]interface{}, sessionID string) (map[string]interface{}, error)
ExecuteTool executes a tool via ekoDB's server-side tool pipeline.
Calls POST /api/chat/tools/execute which goes through the same execute_tool function as the LLM tool-calling loop β with all collection filtering, permission enforcement, and internal collection blocking. No LLM round-trip.
Returns the tool result if executed, nil if the server doesn't support the endpoint (older ekoDB versions), or an error.
func (*Client) Exists ΒΆ added in v0.8.0
Exists checks if a record exists by ID Returns true if the record exists, false if it doesn't.
func (*Client) ExtractRecordID ΒΆ added in v0.15.1
ExtractRecordID extracts the record ID from a record map using the schema cache's primary_key_alias for the collection.
func (*Client) Find ΒΆ
func (c *Client) Find(collection string, query interface{}, opts ...FindOptions) ([]Record, error)
Find finds documents in a collection
func (*Client) FindAll ΒΆ added in v0.5.0
FindAll finds all records in a collection with a limit
Simplified method to query all documents in a collection.
Example:
allMessages, err := client.FindAll("messages", 1000)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d messages\n", len(allMessages))
func (*Client) FindByID ΒΆ
func (c *Client) FindByID(collection, id string, opts ...FindByIDOptions) (Record, error)
FindByID finds a document by ID. Pass FindByIDOptions to project fields or to read within a transaction (read-your-writes).
func (*Client) FindByIDWithProjection ΒΆ added in v0.9.0
func (c *Client) FindByIDWithProjection(collection, id string, selectFields, excludeFields []string) (Record, error)
FindByIDWithProjection finds a document by ID with field projection selectFields: only return these fields (plus 'id') excludeFields: exclude these fields from results
func (*Client) FindOne ΒΆ added in v0.8.0
FindOne finds a single record by field value Returns nil if no record matches, or the first matching record.
func (*Client) GetChatMessage ΒΆ added in v0.11.0
GetChatMessage gets a specific message by ID
func (*Client) GetChatModel ΒΆ added in v0.11.0
GetChatModel retrieves available models for a specific provider
func (*Client) GetChatModels ΒΆ added in v0.11.0
func (c *Client) GetChatModels() (*ChatModels, error)
GetChatModels retrieves all available chat models from all providers
func (*Client) GetChatSession ΒΆ
func (c *Client) GetChatSession(sessionID string) (*ChatSessionResponse, error)
GetChatSession gets a chat session by ID
func (*Client) GetChatSessionMessages ΒΆ
func (c *Client) GetChatSessionMessages(sessionID string, query *GetMessagesQuery) (*GetMessagesResponse, error)
GetChatSessionMessages gets messages from a chat session
func (*Client) GetChatTools ΒΆ added in v0.13.0
GetChatTools retrieves all built-in server-side chat tool definitions. Returns a slice of tool objects with name, description, and parameters fields. Used by planning agents to discover available tools dynamically.
func (*Client) GetCollection ΒΆ
func (c *Client) GetCollection(collection string) (*CollectionMetadata, error)
GetCollection gets collection metadata and schema
func (*Client) GetFunction ΒΆ added in v0.16.0
func (c *Client) GetFunction(id string) (*UserFunction, error)
GetFunction retrieves a function by ID
func (*Client) GetRateLimitInfo ΒΆ
func (c *Client) GetRateLimitInfo() *RateLimitInfo
GetRateLimitInfo returns the current rate limit information
func (*Client) GetSchedule ΒΆ added in v0.14.0
GetSchedule retrieves a schedule by ID.
func (*Client) GetSchemaCache ΒΆ added in v0.15.1
func (c *Client) GetSchemaCache() *SchemaCache
GetSchemaCache returns the client's schema cache (may be nil if not enabled).
func (*Client) GetTransactionStatus ΒΆ added in v0.7.0
GetTransactionStatus gets the status of a transaction
func (*Client) GetUserFunction ΒΆ added in v0.11.0
func (c *Client) GetUserFunction(label string) (*UserFunction, error)
GetUserFunction retrieves a user function by label
func (*Client) GoalApprove ΒΆ added in v0.14.0
GoalApprove atomically approves a goal (status β in_progress).
func (*Client) GoalComplete ΒΆ added in v0.14.0
func (c *Client) GoalComplete(id string, data map[string]interface{}) (map[string]interface{}, error)
GoalComplete atomically marks a goal as complete (status β pending_review).
func (*Client) GoalCreate ΒΆ added in v0.14.0
GoalCreate creates a new goal.
func (*Client) GoalDelete ΒΆ added in v0.14.0
GoalDelete deletes a goal by ID.
func (*Client) GoalReject ΒΆ added in v0.14.0
GoalReject atomically rejects a goal (status β failed).
func (*Client) GoalSearch ΒΆ added in v0.14.0
GoalSearch searches goals by query string.
func (*Client) GoalStepComplete ΒΆ added in v0.14.0
func (c *Client) GoalStepComplete(id string, stepIndex int, data map[string]interface{}) (map[string]interface{}, error)
GoalStepComplete atomically marks a goal step as completed.
func (*Client) GoalStepFail ΒΆ added in v0.14.0
func (c *Client) GoalStepFail(id string, stepIndex int, data map[string]interface{}) (map[string]interface{}, error)
GoalStepFail atomically marks a goal step as failed.
func (*Client) GoalStepStart ΒΆ added in v0.14.0
GoalStepStart atomically marks a goal step as in_progress.
func (*Client) GoalTemplateCreate ΒΆ added in v0.14.0
GoalTemplateCreate creates a new goal template.
func (*Client) GoalTemplateDelete ΒΆ added in v0.14.0
GoalTemplateDelete deletes a goal template by ID.
func (*Client) GoalTemplateGet ΒΆ added in v0.14.0
GoalTemplateGet retrieves a goal template by ID.
func (*Client) GoalTemplateList ΒΆ added in v0.14.0
GoalTemplateList lists all goal templates.
func (*Client) GoalTemplateUpdate ΒΆ added in v0.14.0
func (c *Client) GoalTemplateUpdate(id string, data map[string]interface{}) (map[string]interface{}, error)
GoalTemplateUpdate updates a goal template by ID.
func (*Client) GoalUpdate ΒΆ added in v0.14.0
GoalUpdate updates a goal by ID.
func (*Client) Health ΒΆ added in v0.2.0
Health reports whether the ekoDB server is reachable.
It returns nil whenever the server answers /api/health β including when the server reports "degraded" β and returns an error only when the server is unreachable. Use HealthStatus for the "ok" vs "degraded" distinction. This is intentionally reachable-only: gating a connection on "status == ok" conflates readiness with liveness and blocks startup against a degraded-but-serving instance.
func (*Client) HealthStatus ΒΆ added in v0.25.0
func (c *Client) HealthStatus() (*HealthStatus, error)
HealthStatus probes /api/health and returns structured, degraded-tolerant state. See the HealthStatus type for the contract.
func (*Client) HybridSearch ΒΆ added in v0.5.0
func (c *Client) HybridSearch(collection, queryText string, queryVector []float64, limit int) ([]Record, error)
HybridSearch performs hybrid search combining text and vector search
Combines semantic similarity (vector search) with keyword matching (text search) for more accurate and relevant results.
Example:
embedding, _ := client.Embed(query, "text-embedding-3-small")
results, err := client.HybridSearch("documents", query, embedding, 5)
if err != nil {
log.Fatal(err)
}
func (*Client) Insert ΒΆ
Insert inserts a document into a collection Usage:
Insert(collection, record) // basic insert
Insert(collection, record, InsertOptions{TTL: "1h"}) // with TTL
Insert(collection, record, InsertOptions{BypassRipple: &t}) // bypass ripple
func (*Client) IsNearRateLimit ΒΆ
IsNearRateLimit checks if approaching rate limit
func (*Client) KVBatchDelete ΒΆ added in v0.9.0
KVBatchDelete deletes multiple keys in a single request
func (*Client) KVBatchGet ΒΆ added in v0.9.0
KVBatchGet retrieves multiple keys in a single request
func (*Client) KVBatchSet ΒΆ added in v0.9.0
KVBatchSet sets multiple key-value pairs in a single request. TTL from the first entry with a valid TTL is applied to all entries (server limitation).
func (*Client) KVClear ΒΆ added in v0.21.0
KVClear removes every key-value entry from the store (clears the KV namespace).
func (*Client) KVFind ΒΆ added in v0.7.0
KVFind queries/finds KV entries with pattern matching. The pattern supports simple wildcards where '*' matches any sequence of characters in a key. If includeExpired is true, results will also include entries that are past their configured TTL but may still be present in the store.
func (*Client) KVGetLinks ΒΆ added in v0.14.0
KVGetLinks retrieves documents linked to a KV key.
func (*Client) KVQuery ΒΆ added in v0.7.0
KVQuery is an alias for KVFind - queries KV store with pattern
func (*Client) KVUnlink ΒΆ added in v0.14.0
KVUnlink removes a link between a KV key and a document.
func (*Client) ListChatSessions ΒΆ
func (c *Client) ListChatSessions(query *ListSessionsQuery) (*ListSessionsResponse, error)
ListChatSessions lists all chat sessions
func (*Client) ListCollections ΒΆ
ListCollections lists all collections
func (*Client) ListFunctions ΒΆ added in v0.16.0
func (c *Client) ListFunctions(tags []string) ([]UserFunction, error)
ListFunctions lists all functions, optionally filtered by tags
func (*Client) ListSchedules ΒΆ added in v0.14.0
ListSchedules lists all schedules.
func (*Client) ListUserCollections ΒΆ added in v0.21.0
ListUserCollections lists only user-created collections, excluding internal chat/system collections the server maintains. It mirrors the other clients' list_user_collections by passing the server's exclude_internal=true filter.
func (*Client) ListUserFunctions ΒΆ added in v0.11.0
func (c *Client) ListUserFunctions(tags []string) ([]UserFunction, error)
ListUserFunctions lists all user functions, optionally filtered by tags
func (*Client) MergeChatSessions ΒΆ
func (c *Client) MergeChatSessions(request MergeSessionsRequest) (*ChatSessionResponse, error)
MergeChatSessions merges multiple chat sessions into one
func (*Client) Paginate ΒΆ added in v0.8.0
Paginate retrieves records with pagination (1-indexed page numbers) Page 1 = first page, Page 2 = second page, etc. Returns an error if page < 1 or pageSize < 1.
func (*Client) PauseSchedule ΒΆ added in v0.14.0
PauseSchedule pauses a schedule by ID.
func (*Client) RawCompletion ΒΆ added in v0.13.0
func (c *Client) RawCompletion(request RawCompletionRequest) (*RawCompletionResponse, error)
RawCompletion sends a stateless raw LLM completion request β no session, no history, no RAG context injection. Use this for structured-output tasks such as planning where the response must be parsed programmatically.
Example:
resp, err := client.RawCompletion(RawCompletionRequest{
SystemPrompt: "You are a helpful assistant.",
Message: "Summarize this in JSON.",
})
func (*Client) RawCompletionStream ΒΆ added in v0.14.0
func (c *Client) RawCompletionStream(request RawCompletionRequest) (*RawCompletionResponse, error)
RawCompletionStream performs a stateless raw LLM completion via SSE streaming.
Same as RawCompletion but uses Server-Sent Events to keep the connection alive. Preferred for deployed instances where reverse proxies may kill idle HTTP connections before the LLM responds.
func (*Client) RawCompletionStreamWithProgress ΒΆ added in v0.14.0
func (c *Client) RawCompletionStreamWithProgress(request RawCompletionRequest, onToken func(string)) (*RawCompletionResponse, error)
RawCompletionStreamWithProgress performs a stateless raw LLM completion via SSE streaming, calling onToken for each token as it arrives.
Same as RawCompletionStream but provides incremental progress via the callback, allowing callers to show real-time output during long-running LLM calls.
func (*Client) RefreshToken ΒΆ added in v0.21.0
RefreshToken forces a fresh authentication token to be fetched immediately (bypassing any cached token) and returns it. Parity with the other clients' refresh_token; unlike ClearTokenCache, which defers the fetch to the next request, this fetches eagerly.
func (*Client) RegenerateChatMessage ΒΆ
func (c *Client) RegenerateChatMessage(sessionID, messageID string) (*ChatResponse, error)
RegenerateChatMessage regenerates an AI response message
func (*Client) ReleaseSavepoint ΒΆ added in v0.21.0
ReleaseSavepoint releases (forgets) a savepoint. Staged work is unaffected.
func (*Client) RestoreCollection ΒΆ added in v0.8.0
RestoreCollection restores all deleted records in a collection from trash Records remain in trash for 30 days before permanent deletion
func (*Client) RestoreRecord ΒΆ added in v0.8.0
RestoreRecord restores a deleted record from trash Records remain in trash for 30 days before permanent deletion
func (*Client) ResumeSchedule ΒΆ added in v0.14.0
ResumeSchedule resumes a schedule by ID.
func (*Client) RollbackToSavepoint ΒΆ added in v0.21.0
RollbackToSavepoint rolls the transaction back to a savepoint, discarding writes staged after it.
func (*Client) RollbackTransaction ΒΆ added in v0.7.0
RollbackTransaction rolls back a transaction, discarding all staged writes (nothing was applied).
func (*Client) SaveFunction ΒΆ added in v0.16.0
func (c *Client) SaveFunction(function UserFunction) (string, error)
SaveFunction creates a new function
func (*Client) SaveUserFunction ΒΆ added in v0.11.0
func (c *Client) SaveUserFunction(userFunction UserFunction) (string, error)
SaveUserFunction creates a new reusable user function
func (*Client) Search ΒΆ
func (c *Client) Search(collection string, searchQuery SearchQuery) (*SearchResponse, error)
Search performs a search query on a collection
func (*Client) SubmitChatToolKeepalive ΒΆ added in v0.22.0
SubmitChatToolKeepalive sends a liveness ping for an in-flight client tool. It is NOT a result: it resets the server's per-tool wait deadline (config client_tool_timeout_secs, default 60s) so a slow confirmation or a long-running tool doesn't get the turn timed out mid-response. Send it periodically while the tool is still working, then call SubmitChatToolResult once when it completes (pairs with ekoDB#530).
func (*Client) SubmitChatToolResult ΒΆ added in v0.16.0
func (c *Client) SubmitChatToolResult(sessionID, callID string, success bool, result interface{}, errMsg string) error
SubmitChatToolResult submits a client tool result for an in-flight SSE chat stream. This unblocks ekoDB's tool loop so it can feed the result to the LLM.
func (*Client) SubscribeSSE ΒΆ added in v0.16.0
func (c *Client) SubscribeSSE(ctx context.Context, collection string, opts *SubscribeSSEOptions) (*SSESubscription, error)
SubscribeSSE subscribes to collection mutations via SSE (Server-Sent Events).
Returns an SSESubscription whose Events channel yields MutationNotification events and whose Err channel surfaces any stream-level error. Both channels are closed when the stream ends or the context is cancelled.
Cancel the context to stop the subscription and release resources.
Use this when WebSocket connections aren't available (e.g. behind reverse proxies that block WS upgrades).
func (*Client) TaskCreate ΒΆ added in v0.14.0
TaskCreate creates a new scheduled task.
func (*Client) TaskDelete ΒΆ added in v0.14.0
TaskDelete deletes a task by ID.
func (*Client) TaskResume ΒΆ added in v0.14.0
TaskResume atomically resumes a paused task.
func (*Client) TaskSucceed ΒΆ added in v0.14.0
func (c *Client) TaskSucceed(id string, data map[string]interface{}) (map[string]interface{}, error)
TaskSucceed atomically marks a task as succeeded.
func (*Client) TaskUpdate ΒΆ added in v0.14.0
TaskUpdate updates a task by ID.
func (*Client) TextSearch ΒΆ added in v0.5.0
TextSearch performs text search without embeddings
Simplified text search with full-text matching, fuzzy search, and stemming.
Example:
results, err := client.TextSearch("documents", "ownership system", 10)
if err != nil {
log.Fatal(err)
}
func (*Client) ToggleForgottenMessage ΒΆ
ToggleForgottenMessage toggles the "forgotten" status of a message
func (*Client) Update ΒΆ
func (c *Client) Update(collection, id string, record Record, opts ...UpdateOptions) (Record, error)
Update updates a document
func (*Client) UpdateChatMessage ΒΆ
UpdateChatMessage updates a specific message
func (*Client) UpdateChatSession ΒΆ
func (c *Client) UpdateChatSession(sessionID string, request UpdateSessionRequest) (*ChatSessionResponse, error)
UpdateChatSession updates a chat session
func (*Client) UpdateFunction ΒΆ added in v0.16.0
func (c *Client) UpdateFunction(id string, function UserFunction) error
UpdateFunction updates an existing function by ID
func (*Client) UpdateSchedule ΒΆ added in v0.14.0
func (c *Client) UpdateSchedule(id string, data map[string]interface{}) (map[string]interface{}, error)
UpdateSchedule updates a schedule by ID.
func (*Client) UpdateUserFunction ΒΆ added in v0.11.0
func (c *Client) UpdateUserFunction(label string, userFunction UserFunction) error
UpdateUserFunction updates an existing user function by label
func (*Client) UpdateWithAction ΒΆ added in v0.13.0
func (c *Client) UpdateWithAction(collection, id, action, field string, value interface{}) (Record, error)
UpdateWithAction applies an atomic field action to a single field of a record.
Use this instead of Update() for safe concurrent modifications like incrementing counters, pushing to arrays, or arithmetic operations.
Supported actions: increment, decrement, multiply, divide, modulo, push, pop, shift, unshift, remove, append, clear.
func (*Client) UpdateWithActionSequence ΒΆ added in v0.13.0
func (c *Client) UpdateWithActionSequence(collection, id string, actions [][3]interface{}) (Record, error)
UpdateWithActionSequence applies a sequence of atomic field actions to a record in a single request. All actions are applied atomically β the record is fetched once, all actions run in order, and the result is persisted in a single update.
Each action is a 3-element slice: [action, field, value].
type ClientConfig ΒΆ
type ClientConfig struct {
BaseURL string // Base URL of the ekoDB server
APIKey string // API key for authentication
ShouldRetry bool // Enable automatic retries (default: true)
MaxRetries int // Maximum number of retry attempts (default: 3)
Timeout time.Duration // Request timeout (default: 30s)
Format SerializationFormat // Serialization format (default: MessagePack for best performance, use JSON for debugging)
}
ClientConfig contains configuration options for the client
type ClientToolDef ΒΆ added in v0.16.0
type ClientToolDef struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters interface{} `json:"parameters"`
}
ClientToolDef defines a client-side tool the LLM can call (HTTP path).
type ClientToolDefinition ΒΆ added in v0.13.0
type ClientToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters interface{} `json:"parameters"`
}
ClientToolDefinition defines a client-side tool the LLM can call.
type CollectionConfig ΒΆ
type CollectionConfig struct {
CollectionName string `json:"collection_name"`
Fields []interface{} `json:"fields"`
SearchOptions interface{} `json:"search_options,omitempty"`
}
CollectionConfig represents configuration for searching a specific collection
type CollectionMetadata ΒΆ
type CollectionMetadata struct {
Collection Schema `json:"collection"`
Analytics interface{} `json:"analytics,omitempty"`
}
CollectionMetadata represents collection metadata with analytics
type CompactChatRequest ΒΆ added in v0.19.0
type CompactChatRequest struct {
KeepRecent *int `json:"keep_recent,omitempty"`
}
CompactChatRequest is the request body for POST /api/chat/{chat_id}/compact. KeepRecent is optional; it is omitted from the JSON body when nil. There is no bypass_ripple: compaction writes chat-message records, which the server does not ripple (same convention as all chat-message writes).
type CompactChatResponse ΒΆ added in v0.19.0
type CompactChatResponse struct {
Folded int `json:"folded"`
KeptRecent int `json:"kept_recent"`
SummaryChars int `json:"summary_chars"`
SummaryMessageID *string `json:"summary_message_id"`
AlreadyCompact bool `json:"already_compact"`
}
CompactChatResponse is the response from POST /api/chat/{chat_id}/compact. SummaryMessageID is nullable (null when nothing was folded).
type CreateChatSessionRequest ΒΆ
type CreateChatSessionRequest struct {
Collections []CollectionConfig `json:"collections"`
LLMProvider string `json:"llm_provider"`
LLMModel *string `json:"llm_model,omitempty"`
SystemPrompt *string `json:"system_prompt,omitempty"`
AgentID *string `json:"agent_id,omitempty"`
BypassRipple *bool `json:"bypass_ripple,omitempty"`
ParentID *string `json:"parent_id,omitempty"`
BranchPointIdx *int `json:"branch_point_idx,omitempty"`
MaxContextMessages *int `json:"max_context_messages,omitempty"`
MaxTokens *int32 `json:"max_tokens,omitempty"`
Temperature *float32 `json:"temperature,omitempty"`
ToolConfig *ToolConfig `json:"tool_config,omitempty"`
}
CreateChatSessionRequest represents a request to create a new chat session
type DeleteOptions ΒΆ added in v0.8.0
DeleteOptions contains optional parameters for Delete
type DistanceMetric ΒΆ
type DistanceMetric string
DistanceMetric represents the distance metric for vector similarity
const ( // DistanceMetricCosine represents cosine similarity DistanceMetricCosine DistanceMetric = "cosine" // DistanceMetricEuclidean represents euclidean distance DistanceMetricEuclidean DistanceMetric = "euclidean" // DistanceMetricDotProduct represents dot product DistanceMetricDotProduct DistanceMetric = "dotproduct" )
type DistinctValuesQuery ΒΆ added in v0.13.0
type DistinctValuesQuery struct {
// Filter restricts which records are examined (optional).
Filter interface{} `json:"filter,omitempty"`
// BypassRipple skips ripple propagation when true.
BypassRipple *bool `json:"bypass_ripple,omitempty"`
// BypassCache skips the cache when true.
BypassCache *bool `json:"bypass_cache,omitempty"`
}
DistinctValuesQuery is the request body for DistinctValues.
type DistinctValuesResponse ΒΆ added in v0.13.0
type DistinctValuesResponse struct {
// Collection that was queried.
Collection string `json:"collection"`
// Field whose distinct values were returned.
Field string `json:"field"`
// Values contains the unique field values, sorted alphabetically.
Values []interface{} `json:"values"`
// Count is the number of distinct values.
Count int `json:"count"`
}
DistinctValuesResponse is returned by DistinctValues.
type EmailSendOptions ΒΆ added in v0.18.0
EmailSendOptions carries the optional fields for StageEmailSend so the builder doesn't grow an unwieldy positional argument list. All fields are individually optional β leave a string empty or a *bool nil to omit it from the on-wire payload.
type EmbedRequest ΒΆ added in v0.12.0
type EmbedRequest struct {
Text *string `json:"text,omitempty"`
Texts []string `json:"texts,omitempty"`
Model *string `json:"model,omitempty"`
}
EmbedRequest is the request body for POST /api/embed
type EmbedResponse ΒΆ added in v0.12.0
type EmbedResponse struct {
Embeddings [][]float64 `json:"embeddings"`
Model string `json:"model"`
Dimensions int `json:"dimensions"`
}
EmbedResponse is the response from POST /api/embed
type ExecuteToolRequest ΒΆ added in v0.15.0
type ExecuteToolRequest struct {
Tool string `json:"tool"`
Params map[string]interface{} `json:"params"`
ChatID string `json:"chat_id,omitempty"`
}
ExecuteToolRequest is the request body for POST /api/chat/tools/execute.
type ExecuteToolResult ΒΆ added in v0.15.0
type ExecuteToolResult struct {
Success bool `json:"success"`
Result map[string]interface{} `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
ExecuteToolResult is the response from POST /api/chat/tools/execute.
type FieldTypeSchema ΒΆ
type FieldTypeSchema struct {
FieldType string `json:"field_type"`
Default interface{} `json:"default,omitempty"`
Unique bool `json:"unique,omitempty"`
Required bool `json:"required,omitempty"`
Enums []interface{} `json:"enums,omitempty"`
Max interface{} `json:"max,omitempty"`
Min interface{} `json:"min,omitempty"`
Regex *string `json:"regex,omitempty"`
Index *IndexConfig `json:"index,omitempty"`
}
FieldTypeSchema represents field type schema with constraints
type FieldTypeSchemaBuilder ΒΆ
type FieldTypeSchemaBuilder struct {
// contains filtered or unexported fields
}
FieldTypeSchemaBuilder provides a fluent API for building field type schemas
func NewFieldTypeSchemaBuilder ΒΆ
func NewFieldTypeSchemaBuilder(fieldType string) *FieldTypeSchemaBuilder
NewFieldTypeSchemaBuilder creates a new FieldTypeSchemaBuilder
func (*FieldTypeSchemaBuilder) BTreeIndex ΒΆ
func (fb *FieldTypeSchemaBuilder) BTreeIndex() *FieldTypeSchemaBuilder
BTreeIndex adds a B-tree index
func (*FieldTypeSchemaBuilder) Build ΒΆ
func (fb *FieldTypeSchemaBuilder) Build() FieldTypeSchema
Build builds the final FieldTypeSchema
func (*FieldTypeSchemaBuilder) DefaultValue ΒΆ
func (fb *FieldTypeSchemaBuilder) DefaultValue(value interface{}) *FieldTypeSchemaBuilder
DefaultValue sets a default value
func (*FieldTypeSchemaBuilder) Enums ΒΆ
func (fb *FieldTypeSchemaBuilder) Enums(values []interface{}) *FieldTypeSchemaBuilder
Enums sets enum values
func (*FieldTypeSchemaBuilder) HashIndex ΒΆ
func (fb *FieldTypeSchemaBuilder) HashIndex() *FieldTypeSchemaBuilder
HashIndex adds a hash index
func (*FieldTypeSchemaBuilder) Pattern ΒΆ
func (fb *FieldTypeSchemaBuilder) Pattern(regex string) *FieldTypeSchemaBuilder
Pattern sets regex pattern
func (*FieldTypeSchemaBuilder) Range ΒΆ
func (fb *FieldTypeSchemaBuilder) Range(min, max interface{}) *FieldTypeSchemaBuilder
Range sets min/max range
func (*FieldTypeSchemaBuilder) Required ΒΆ
func (fb *FieldTypeSchemaBuilder) Required() *FieldTypeSchemaBuilder
Required sets the field as required
func (*FieldTypeSchemaBuilder) TextIndex ΒΆ
func (fb *FieldTypeSchemaBuilder) TextIndex(language string) *FieldTypeSchemaBuilder
TextIndex adds a text index
func (*FieldTypeSchemaBuilder) Unique ΒΆ
func (fb *FieldTypeSchemaBuilder) Unique() *FieldTypeSchemaBuilder
Unique sets the field as unique
func (*FieldTypeSchemaBuilder) VectorIndex ΒΆ
func (fb *FieldTypeSchemaBuilder) VectorIndex(algorithm VectorIndexAlgorithm, metric DistanceMetric, m, efConstruction int) *FieldTypeSchemaBuilder
VectorIndex adds a vector index
type FieldValue ΒΆ added in v0.6.1
type FieldValue struct {
Type string `json:"type"`
Value interface{} `json:"value"`
}
FieldValue represents an ekoDB field with type and value
type FindByIDOptions ΒΆ added in v0.21.0
type FindByIDOptions struct {
SelectFields []string
ExcludeFields []string
// BypassRipple skips ripple propagation for this read. Sent as the
// bypass_ripple GET query param (the same way the non-transactional read
// carries it) and rides alongside transaction_id when both are set. Nil
// leaves it off.
BypassRipple *bool
TransactionId *string
}
FindByIDOptions contains optional parameters for FindByID, including read-your-writes within a transaction (see FindOptions.TransactionId).
type FindOptions ΒΆ added in v0.8.0
type FindOptions struct {
Filter interface{}
Sort interface{}
Limit *int
Skip *int
Join interface{}
BypassCache *bool
BypassRipple *bool
SelectFields []string
ExcludeFields []string
// TransactionId reads within a transaction (read-your-writes): the read is
// served from the transaction's own view β its uncommitted staged writes,
// else the committed store β and recorded in its read set for commit-time
// conflict detection. Nil for an ordinary committed read.
TransactionId *string
}
FindOptions carries optional shaping for Find. Filter, Sort, Limit, Skip, Join, BypassCache, SelectFields, and ExcludeFields are merged into the request body (the server's FindBody); when one is set here it overrides the same field carried in the query argument. TransactionId and BypassRipple are sent as query parameters instead, not in the FindBody β TransactionId because the read runs in the transaction's read-your-writes view, and BypassRipple to match how every other method (Insert/Update/FindByID) carries it.
type FunctionCondition ΒΆ added in v0.16.0
type FunctionCondition struct {
Type string // Condition type (HasRecords, FieldEquals, CountEquals, And, Or, Not, etc.)
Field string // Field name for field-based conditions
FieldValue interface{} // Expected value for comparison conditions (FieldEquals)
Count int // Count threshold for count-based conditions
Conditions []FunctionCondition // Child conditions for And/Or operators
Condition *FunctionCondition // Single child condition for Not operator
}
FunctionCondition represents a conditional expression for If stages in functions. Conditions are evaluated against the current pipeline state (records, counts, field values) and can be composed using logical operators (And, Or, Not).
Example usage:
cond := ConditionAnd([]FunctionCondition{
ConditionHasRecords(),
ConditionCountGreaterThan(5),
})
StageIf(cond, thenFunctions, elseFunctions)
func ConditionAnd ΒΆ added in v0.6.0
func ConditionAnd(conditions []FunctionCondition) FunctionCondition
ConditionAnd creates a condition that requires all of the provided child conditions to be satisfied (logical AND). All conditions are evaluated and must pass.
func ConditionCountEquals ΒΆ added in v0.6.0
func ConditionCountEquals(count int) FunctionCondition
ConditionCountEquals creates a condition that is satisfied when the number of records in the current pipeline stage exactly equals the provided count.
func ConditionCountGreaterThan ΒΆ added in v0.6.0
func ConditionCountGreaterThan(count int) FunctionCondition
ConditionCountGreaterThan creates a condition that is satisfied when the number of records in the current pipeline stage is strictly greater than the provided count.
func ConditionCountLessThan ΒΆ added in v0.6.0
func ConditionCountLessThan(count int) FunctionCondition
ConditionCountLessThan creates a condition that is satisfied when the number of records in the current pipeline stage is strictly less than the provided count.
func ConditionFieldEquals ΒΆ added in v0.6.0
func ConditionFieldEquals(field string, value interface{}) FunctionCondition
ConditionFieldEquals creates a condition that is satisfied when the specified field in the current record(s) equals the provided value. Field comparison is type-aware.
func ConditionFieldExists ΒΆ added in v0.6.0
func ConditionFieldExists(field string) FunctionCondition
ConditionFieldExists creates a condition that is satisfied when the specified field exists in the current record(s), regardless of its value (including null).
func ConditionHasRecords ΒΆ added in v0.6.0
func ConditionHasRecords() FunctionCondition
ConditionHasRecords creates a condition that is satisfied when the current pipeline stage has one or more records. Useful for checking if a query returned any results.
func ConditionNot ΒΆ added in v0.6.0
func ConditionNot(condition FunctionCondition) FunctionCondition
ConditionNot creates a condition that inverts the result of the provided child condition (logical NOT). Returns true when the child condition is false.
func ConditionOr ΒΆ added in v0.6.0
func ConditionOr(conditions []FunctionCondition) FunctionCondition
ConditionOr creates a condition that is satisfied when at least one of the provided child conditions is satisfied (logical OR). Evaluation may short-circuit.
func (FunctionCondition) MarshalJSON ΒΆ added in v0.16.0
func (c FunctionCondition) MarshalJSON() ([]byte, error)
MarshalJSON implements adjacently-tagged serialization for FunctionCondition. Format: { "type": "...", "value": { ...data } } for variants with data Unit variants like HasRecords have no value field.
type FunctionResult ΒΆ added in v0.4.0
type FunctionResult struct {
Records []map[string]interface{} `json:"records"`
Stats FunctionStats `json:"stats"`
}
FunctionResult from execution
type FunctionStageConfig ΒΆ added in v0.4.0
type FunctionStageConfig struct {
Stage string `json:"stage"`
Data map[string]interface{} `json:",inline"`
}
FunctionStageConfig represents a pipeline stage
func StageAesDecrypt ΒΆ added in v0.18.0
func StageAesDecrypt(ciphertextField, key, outputField, keyEncoding string) FunctionStageConfig
StageAesDecrypt reads the {ciphertext, nonce} envelope from ciphertextField on the first working record, decrypts with key, and writes the recovered plaintext (or null on tag mismatch) to outputField.
func StageAesEncrypt ΒΆ added in v0.18.0
func StageAesEncrypt(plaintext, key, outputField, keyEncoding string) FunctionStageConfig
StageAesEncrypt encrypts plaintext with AES-256-GCM and writes the {ciphertext, nonce} envelope (both base64) to outputField. Pass "" for keyEncoding to default to "hex"; "base64" and "base64url" are also supported. Use "{{env.DATA_KEY}}" for key.
func StageBase64Decode ΒΆ added in v0.18.0
func StageBase64Decode(input, outputField string, urlSafe *bool) FunctionStageConfig
StageBase64Decode decodes input as base64 and writes the recovered UTF-8 string (or null on bad input) to outputField. Fail-closed.
func StageBase64Encode ΒΆ added in v0.18.0
func StageBase64Encode(input, outputField string, urlSafe *bool) FunctionStageConfig
StageBase64Encode base64-encodes input and writes to outputField. Pass urlSafe = true for URL-safe / no-pad alphabet.
func StageBatchDelete ΒΆ added in v0.4.0
func StageBatchDelete(collection string, ids []string, bypassRipple bool) FunctionStageConfig
func StageBatchInsert ΒΆ added in v0.4.0
func StageBatchInsert(collection string, records []map[string]interface{}, bypassRipple bool) FunctionStageConfig
StageBatchInsert inserts multiple records into a collection
func StageBcryptHash ΒΆ added in v0.17.0
func StageBcryptHash(plain, outputField string, cost *int) FunctionStageConfig
StageBcryptHash bcrypt-hashes a plaintext value and writes the result into every record in the working data as outputField. Use in a compound users_register function between input validation and Insert.
The plain argument is typically a text-level placeholder like "{{password}}" β the substituter replaces it with the call-time param before this stage runs. The cost argument is the bcrypt work factor. ekoDB accepts values in the range 4..=31; pass nil for the ekoDB default (12). This builder does not validate the range client-side, so invalid values will error when the stage is executed by ekoDB.
Requires ekoDB >= 0.41.0.
func StageBcryptVerify ΒΆ added in v0.17.0
func StageBcryptVerify(plain, hashField, outputField string) FunctionStageConfig
StageBcryptVerify verifies a plaintext against a bcrypt hash stored on the first record in the working data and writes a boolean result into outputField. Pair with StageIf to branch on success / failure.
plain is typically "{{password}}"; hashField is the name of the field on the current record holding the stored hash (e.g. "password_hash").
Requires ekoDB >= 0.41.0.
func StageCallFunction ΒΆ added in v0.6.0
func StageCallFunction(functionLabel string, params map[string]interface{}) FunctionStageConfig
StageCallFunction calls a saved UserFunction by label
func StageChat ΒΆ added in v0.4.0
func StageChat(messages []ChatMessage, model *string, temperature *float64) FunctionStageConfig
func StageCount ΒΆ added in v0.4.0
func StageCount(outputField string) FunctionStageConfig
func StageCreateSavepoint ΒΆ added in v0.6.0
func StageCreateSavepoint(name string) FunctionStageConfig
StageCreateSavepoint creates a savepoint for partial rollback
func StageDelete ΒΆ added in v0.4.0
func StageDelete(collection string, filter interface{}, bypassRipple bool) FunctionStageConfig
StageDelete deletes records matching a filter (use StageDeleteById for ID-based deletion)
func StageDeleteById ΒΆ added in v0.4.0
func StageDeleteById(collection string, recordId string, bypassRipple bool) FunctionStageConfig
StageDeleteById deletes a specific record by ID
func StageEmailSend ΒΆ added in v0.18.0
func StageEmailSend(to, subject, body, from, apiKey string, opts *EmailSendOptions) FunctionStageConfig
StageEmailSend sends a transactional email through a provider's REST API. Today only provider = "sendgrid" is supported. Use "{{env.SENDGRID_API_KEY}}" for apiKey so the LLM never sees the operator-owned secret. The result envelope ({provider_status, provider_message, provider}) is written to outputField (default "email_send"). Pass nil opts (or a zero-value EmailSendOptions) for the minimal call.
Requires ekoDB >= 0.42.0.
func StageEmbed ΒΆ added in v0.4.0
func StageEmbed(texts interface{}, model *string) FunctionStageConfig
func StageFindAll ΒΆ added in v0.4.0
func StageFindAll(collection string) FunctionStageConfig
Stage builders
func StageFindById ΒΆ added in v0.6.0
func StageFindById(collection string, recordId string) FunctionStageConfig
StageFindById finds a specific record by ID
func StageFindOne ΒΆ added in v0.6.0
func StageFindOne(collection string, key string, value interface{}) FunctionStageConfig
StageFindOne finds one record by key/value pair
func StageFindOneAndUpdate ΒΆ added in v0.6.0
func StageFindOneAndUpdate(collection string, recordId string, updates map[string]interface{}, bypassRipple bool, ttl *int64) FunctionStageConfig
StageFindOneAndUpdate finds and updates a record atomically
func StageForEach ΒΆ added in v0.6.0
func StageForEach(functions []FunctionStageConfig) FunctionStageConfig
StageForEach executes functions for each record
func StageGroup ΒΆ added in v0.4.0
func StageGroup(by_fields []string, functions []GroupFunctionConfig) FunctionStageConfig
func StageHexDecode ΒΆ added in v0.18.0
func StageHexDecode(input, outputField string) FunctionStageConfig
StageHexDecode decodes input as hex and writes the UTF-8 string (or null on bad input) to outputField. Fail-closed.
func StageHexEncode ΒΆ added in v0.18.0
func StageHexEncode(input, outputField string) FunctionStageConfig
StageHexEncode hex-encodes (lowercase) input and writes to outputField.
func StageHmacSign ΒΆ added in v0.18.0
func StageHmacSign(input, secret, outputField, algorithm, encoding string) FunctionStageConfig
StageHmacSign signs an input with HMAC-SHA256/384/512 and writes the resulting digest (hex or base64) to outputField on every working record. Pass "" for algorithm to default to "sha256", and "" for encoding to default to "hex". Use "{{env.SIGNING_KEY}}" for secret so the LLM never sees the operator-owned key.
Requires ekoDB >= 0.42.0.
func StageHmacVerify ΒΆ added in v0.18.0
func StageHmacVerify(input, providedMac, secret, outputField, algorithm, encoding string) FunctionStageConfig
StageHmacVerify verifies an HMAC against providedMac in constant time and writes a boolean to outputField. Pass "" for algorithm and encoding to default to "sha256" + "hex".
func StageHttpRequest ΒΆ added in v0.4.0
func StageHttpRequest(url, method string, headers map[string]string, body interface{}) FunctionStageConfig
func StageHybridSearch ΒΆ added in v0.4.0
func StageHybridSearch(collection string, queryText string, queryVector []float64, options map[string]interface{}) FunctionStageConfig
func StageIdempotencyClaim ΒΆ added in v0.18.0
func StageIdempotencyClaim(key string, ttlSecs uint64, outputField string) FunctionStageConfig
StageIdempotencyClaim atomically claims an idempotency key (KV SETNX with TTL). On first call writes {claimed: true, key} to outputField; on replay within ttlSecs writes {claimed: false, key, response} so the caller can short-circuit. Requires ekoDB >= 0.42.0.
func StageIf ΒΆ added in v0.6.0
func StageIf(condition FunctionCondition, thenFunctions []FunctionStageConfig, elseFunctions []FunctionStageConfig) FunctionStageConfig
StageIf executes functions conditionally
func StageInsert ΒΆ added in v0.4.0
func StageInsert(collection string, record map[string]interface{}, bypassRipple bool, ttl *int64) FunctionStageConfig
StageInsert inserts a single record into a collection
func StageJwtSign ΒΆ added in v0.18.0
func StageJwtSign(claims map[string]interface{}, secret, outputField string, expiresInSecs *int64, algorithm string) FunctionStageConfig
StageJwtSign signs a JWT and writes the resulting token to every working record. Pair with StageBcryptVerify to issue a session token after login. Use "{{env.JWT_SECRET}}" for secret so the LLM never sees the operator-owned signing key. iat and exp are auto-stamped when expiresInSecs is non-nil.
algorithm is one of "HS256", "HS384", "HS512"; pass an empty string to use the server default (HS256 in current ekoDB releases).
Requires ekoDB >= 0.42.0.
func StageJwtVerify ΒΆ added in v0.18.0
func StageJwtVerify(tokenField, secret, outputField, algorithm string) FunctionStageConfig
StageJwtVerify verifies a JWT held in tokenField on the first working record. On success writes the decoded claims object into outputField; on failure writes JSON null. To reject in the pipeline, branch with StageIf checking that the value at outputField on the working record is nil/null (e.g. working_data[0][outputField] == nil), not the outputField string argument itself.
algorithm is one of "HS256", "HS384", "HS512"; pass an empty string to use the server default (HS256 in current ekoDB releases).
Requires ekoDB >= 0.42.0.
func StageKvDelete ΒΆ added in v0.7.0
func StageKvDelete(key string) FunctionStageConfig
StageKvDelete deletes a key from the KV store
func StageKvExists ΒΆ added in v0.7.0
func StageKvExists(key string, outputField *string) FunctionStageConfig
StageKvExists checks if a key exists in the KV store
func StageKvGet ΒΆ added in v0.7.0
func StageKvGet(key string) FunctionStageConfig
StageKvGet retrieves a value from the KV store. Returns {value: <data>} on hit, {value: null} on miss.
func StageKvQuery ΒΆ added in v0.7.0
func StageKvQuery(pattern *string, includeExpired bool) FunctionStageConfig
StageKvQuery queries the KV store with a pattern
func StageKvSet ΒΆ added in v0.7.0
func StageKvSet(key string, value interface{}, ttl *int64) FunctionStageConfig
StageKvSet stores a value in the KV store
func StageLockAcquire ΒΆ added in v0.18.0
func StageLockAcquire(key string, ttlSecs uint64, outputField string) FunctionStageConfig
StageLockAcquire tries to claim a distributed lock under key for ttlSecs. On success writes {acquired: true, token} to outputField; pass that token back to StageLockRelease.
func StageLockRelease ΒΆ added in v0.18.0
func StageLockRelease(key, token, outputField string) FunctionStageConfig
StageLockRelease releases the distributed lock at key only when the stored token matches the supplied token (prevents foreign release after a lease expired and the lock was reclaimed).
func StageParallel ΒΆ added in v0.17.0
func StageParallel(functions []FunctionStageConfig, waitForAll bool) FunctionStageConfig
StageParallel executes multiple functions in parallel (concurrently). All functions run simultaneously, results are merged. If waitForAll is true, waits for all to complete; if false, returns on first completion.
func StageProject ΒΆ added in v0.4.0
func StageProject(fields []string, exclude bool) FunctionStageConfig
StageProject selects or excludes specific fields from results exclude=false means include only these fields, exclude=true means exclude these fields
func StageQuery ΒΆ added in v0.4.0
func StageQuery(collection string, filter interface{}, sort []SortFieldConfig, limit, skip *int) FunctionStageConfig
StageQuery queries a collection with optional filter, sort, limit, skip
func StageRandomToken ΒΆ added in v0.17.0
func StageRandomToken(bytes int, encoding, outputField string) FunctionStageConfig
StageRandomToken generates a cryptographically-random token and adds it to every record in the working data. encoding is one of "hex" (default), "base64", or "base64url"; pass an empty string to use the server default. The bytes argument controls the token length; ekoDB enforces a server-side limit of 1..=1024 β this builder does not validate the range client-side, so out-of-range values will error when the stage is executed by ekoDB.
Requires ekoDB >= 0.41.0.
func StageRateLimit ΒΆ added in v0.18.0
func StageRateLimit(key string, limit, windowSecs uint64, outputField, onExceed string) FunctionStageConfig
StageRateLimit gates a pipeline behind a fixed-window counter. Atomically increments rate:<key>:<window-floor>; if the new count exceeds limit, behavior depends on onExceed: "fail" (default β stage errors and stops the pipeline) or "skip" (writes {allowed: false, count, limit} and lets downstream stages branch). Pass "" for onExceed to use the default.
func StageReleaseSavepoint ΒΆ added in v0.6.0
func StageReleaseSavepoint(name string) FunctionStageConfig
StageReleaseSavepoint releases a savepoint
func StageReturn ΒΆ added in v0.17.0
func StageReturn(fields map[string]interface{}, statusCode int) FunctionStageConfig
StageReturn creates a Return stage that shapes the final response. fields are the fields to include in the response (supports {{param}} substitution). statusCode is the HTTP status code (pass 0 to omit; default on server: 200).
func StageRollbackToSavepoint ΒΆ added in v0.6.0
func StageRollbackToSavepoint(name string) FunctionStageConfig
StageRollbackToSavepoint rolls back to a specific savepoint
func StageSWR ΒΆ added in v0.9.0
func StageSWR( cacheKey string, ttl interface{}, url string, method string, headers map[string]string, body interface{}, timeoutSeconds *int, outputField *string, collection *string, ) FunctionStageConfig
StageSWR creates a Stale-While-Revalidate pattern for external API caching. Automatically handles: KV cache check β HTTP request β KV cache set β optional audit storage.
Parameters:
- cacheKey: KV key for caching (supports parameter substitution like "user:{{user_id}}")
- ttl: Cache TTL - server accepts duration strings ("15m", "1h"), integers (seconds), or ISO timestamps
- url: HTTP URL to fetch from (supports parameter substitution)
- method: HTTP method (e.g., "GET", "POST")
- headers: Optional HTTP headers
- body: Optional HTTP request body
- timeoutSeconds: Optional HTTP timeout
- outputField: Field name for response in enriched params (nil uses server default "response")
- collection: Optional collection for audit trail storage
func StageSleep ΒΆ added in v0.17.0
func StageSleep(durationMs interface{}) FunctionStageConfig
StageSleep creates a sleep/delay stage for rate limiting or timing control. durationMs is the duration in milliseconds β pass an int or a string like "{{delay_param}}".
func StageSlugify ΒΆ added in v0.18.0
func StageSlugify(input, outputField string) FunctionStageConfig
StageSlugify converts input to a URL-friendly slug (ASCII-folded, lowercased, non-alphanumerics replaced with "-") and writes to outputField.
func StageTextSearch ΒΆ added in v0.4.0
func StageTextSearch(collection string, queryText string, options map[string]interface{}) FunctionStageConfig
func StageTotpGenerate ΒΆ added in v0.18.0
func StageTotpGenerate(secret, outputField string, opts *TotpOptions) FunctionStageConfig
StageTotpGenerate generates the current TOTP code (RFC 6238) for secret (base32-encoded; typically "{{env.TOTP_SECRET}}") and writes it to outputField. Pass nil opts for all server defaults.
func StageTotpVerify ΒΆ added in v0.18.0
func StageTotpVerify(code, secret, outputField string, opts *TotpOptions) FunctionStageConfig
StageTotpVerify verifies a user-submitted TOTP code against secret and writes a boolean to outputField. Pass nil opts for all server defaults.
func StageTryCatch ΒΆ added in v0.17.0
func StageTryCatch(tryFunctions, catchFunctions []FunctionStageConfig, outputErrorField string) FunctionStageConfig
StageTryCatch creates a try/catch error handling stage for graceful failure recovery. Executes tryFunctions, and if any fail, executes catchFunctions. outputErrorField (optional) is the field name to store error details (default: "error").
func StageUpdate ΒΆ added in v0.6.0
func StageUpdate(collection string, filter interface{}, updates map[string]interface{}, bypassRipple bool, ttl *int64) FunctionStageConfig
StageUpdate updates records matching a filter
func StageUpdateById ΒΆ added in v0.6.0
func StageUpdateById(collection string, recordId string, updates map[string]interface{}, bypassRipple bool, ttl *int64) FunctionStageConfig
StageUpdateById updates a specific record by ID
func StageUpdateWithAction ΒΆ added in v0.6.0
func StageUpdateWithAction(collection string, recordId string, action string, field string, value interface{}, bypassRipple bool) FunctionStageConfig
StageUpdateWithAction updates a record with a specific action (push, pop, increment, decrement, remove). Use the UpdateAction constants for type safety: UpdateActionPush, UpdateActionPop, UpdateActionIncrement, UpdateActionDecrement, UpdateActionRemove.
func StageUuidGenerate ΒΆ added in v0.18.0
func StageUuidGenerate(outputField string) FunctionStageConfig
StageUuidGenerate writes a fresh v4 UUID to outputField on every working record.
func StageValidate ΒΆ added in v0.17.0
func StageValidate(schema map[string]interface{}, dataField string, onError []FunctionStageConfig) FunctionStageConfig
StageValidate validates data against a JSON schema before processing. schema is the JSON Schema to validate against. dataField is the field containing data to validate. onError (optional) are functions to execute on validation failure; pass nil to omit.
func StageVectorSearch ΒΆ added in v0.4.0
func StageVectorSearch(collection string, queryVector []float64, limit *int, threshold *float64) FunctionStageConfig
StageVectorSearch performs vector similarity search
func (FunctionStageConfig) MarshalJSON ΒΆ added in v0.4.0
func (f FunctionStageConfig) MarshalJSON() ([]byte, error)
MarshalJSON custom marshaling for FunctionStageConfig
type FunctionStats ΒΆ added in v0.4.0
type FunctionStats struct {
InputCount int `json:"input_count"`
OutputCount int `json:"output_count"`
ExecutionTimeMs int64 `json:"execution_time_ms"`
StagesExecuted int `json:"stages_executed"`
StageStats []StageStats `json:"stage_stats"`
}
FunctionStats contains execution statistics
type GetMessagesQuery ΒΆ
type GetMessagesQuery struct {
Limit *int `json:"limit,omitempty"`
Skip *int `json:"skip,omitempty"`
Sort *string `json:"sort,omitempty"`
}
GetMessagesQuery represents query parameters for getting messages
type GetMessagesResponse ΒΆ
type GetMessagesResponse struct {
Messages []Record `json:"messages"`
Total int `json:"total"`
Skip int `json:"skip"`
Limit *int `json:"limit,omitempty"`
Returned int `json:"returned"`
}
GetMessagesResponse represents a response containing messages
type GroupFunctionConfig ΒΆ added in v0.4.0
type GroupFunctionConfig struct {
OutputField string `json:"output_field"`
Operation GroupFunctionOp `json:"operation"`
InputField *string `json:"input_field,omitempty"`
}
GroupFunctionConfig for Group stage
type GroupFunctionOp ΒΆ added in v0.4.0
type GroupFunctionOp string
const ( GroupFunctionSum GroupFunctionOp = "Sum" GroupFunctionAverage GroupFunctionOp = "Average" GroupFunctionCount GroupFunctionOp = "Count" GroupFunctionMin GroupFunctionOp = "Min" GroupFunctionMax GroupFunctionOp = "Max" GroupFunctionFirst GroupFunctionOp = "First" GroupFunctionLast GroupFunctionOp = "Last" GroupFunctionPush GroupFunctionOp = "Push" )
type HTTPError ΒΆ added in v0.7.0
HTTPError represents an HTTP error with status code
func (*HTTPError) IsNotFound ΒΆ added in v0.7.0
IsNotFound checks if the error is a 404 Not Found error
type HealthState ΒΆ added in v0.25.0
type HealthState string
HealthState is a health status value reported by ekoDB's /api/health.
const ( HealthOK HealthState = "ok" HealthDegraded HealthState = "degraded" // HealthUnknown is the Status of a snapshot returned when the server is // unreachable or its response is unparseable (always paired with a non-nil // error), so the serialized snapshot carries a meaningful status rather than // an empty string. HealthUnknown HealthState = "unknown" )
HealthOK and HealthDegraded are the possible HealthStatus.Status values. Consumers should compare against these constants rather than bare literals.
type HealthStatus ΒΆ added in v0.25.0
type HealthStatus struct {
Reachable bool `json:"reachable"` // a valid /api/health response came back
Status HealthState `json:"status"` // HealthOK | HealthDegraded | HealthUnknown; a missing/odd status on a reachable body -> HealthDegraded
IntegrityOK bool `json:"integrity_ok"` // body integrity_ok (public) or integrity.healthy (admin)
// Detail is the full parsed body (admin responses include internal metrics
// and collection names). It is NOT serialized (json:"-") so surfacing the
// snapshot can't leak internals; read it in-process when you need the raw
// body.
Detail map[string]interface{} `json:"-"`
}
HealthStatus is a snapshot of an ekoDB /api/health probe. Its JSON form is a safe summary (reachable/status/integrity_ok); Detail is excluded (json:"-") so a consumer can surface the snapshot without leaking the internal body.
It is degraded-tolerant: a reachable server that reports degraded is a successful result (err == nil) with Status == HealthDegraded, NOT an error. When the server is unreachable (connection refused, timeout, non-2xx, or an unparseable body) a non-nil snapshot with Reachable == false and Status == HealthUnknown is returned alongside the error.
Consumers MUST base connection/liveness decisions on Reachable (or err == nil) and treat degraded as a warning, never as a fatal or reconnect trigger. The ekoDB server intentionally returns HTTP 200 while degraded so that liveness probes do not restart a degraded-but-recoverable instance.
func ParseHealthStatus ΒΆ added in v0.25.0
func ParseHealthStatus(body []byte) (*HealthStatus, error)
ParseHealthStatus interprets a raw /api/health response body per the health contract. It is the single source of truth for that interpretation, reused by Client.HealthStatus and by non-client probes (e.g. a service that GETs /api/health with its own HTTP client for circuit-breaking) so every consumer reads health identically.
A parseable body yields a non-nil, Reachable HealthStatus with its reported Status (a missing/odd status fails safe to HealthDegraded). An unparseable body yields a non-nil snapshot with Reachable == false plus an error.
type IndexConfig ΒΆ
type IndexConfig struct {
Type string `json:"type"`
Language *string `json:"language,omitempty"`
Analyzer *string `json:"analyzer,omitempty"`
Algorithm *VectorIndexAlgorithm `json:"algorithm,omitempty"`
Metric *DistanceMetric `json:"metric,omitempty"`
M *int `json:"m,omitempty"`
EfConstruction *int `json:"ef_construction,omitempty"`
}
IndexConfig represents index configuration for a field
type InsertOptions ΒΆ added in v0.8.0
InsertOptions contains optional parameters for Insert
type JoinConfig ΒΆ
type JoinConfig struct {
Collections []string `json:"collections"`
LocalField string `json:"local_field"`
ForeignField string `json:"foreign_field"`
AsField string `json:"as_field"`
}
JoinConfig represents configuration for joining collections
func NewJoinConfig ΒΆ
func NewJoinConfig(collections []string, localField, foreignField, asField string) JoinConfig
NewJoinConfig creates a new join configuration
func NewSingleJoin ΒΆ
func NewSingleJoin(collection, localField, foreignField, asField string) JoinConfig
NewSingleJoin creates a join with a single collection
func (JoinConfig) ToMap ΒΆ
func (j JoinConfig) ToMap() map[string]interface{}
ToMap converts JoinConfig to a map for use in queries
type ListSessionsQuery ΒΆ
type ListSessionsQuery struct {
Limit *int `json:"limit,omitempty"`
Skip *int `json:"skip,omitempty"`
Sort *string `json:"sort,omitempty"`
}
ListSessionsQuery represents query parameters for listing sessions
type ListSessionsResponse ΒΆ
type ListSessionsResponse struct {
Sessions []ChatSession `json:"sessions"`
Total int `json:"total"`
Returned int `json:"returned"`
}
ListSessionsResponse represents a response containing list of sessions
type MergeSessionsRequest ΒΆ
type MergeSessionsRequest struct {
SourceChatIDs []string `json:"source_chat_ids"`
TargetChatID string `json:"target_chat_id"`
MergeStrategy MergeStrategy `json:"merge_strategy"`
BypassRipple *bool `json:"bypass_ripple,omitempty"`
}
MergeSessionsRequest represents a request to merge multiple chat sessions
type MergeStrategy ΒΆ
type MergeStrategy string
MergeStrategy represents how to merge chat sessions
const ( MergeStrategyChronological MergeStrategy = "Chronological" MergeStrategySummarized MergeStrategy = "Summarized" MergeStrategyLatestOnly MergeStrategy = "LatestOnly" MergeStrategyInterleaved MergeStrategy = "Interleaved" )
type MutationNotification ΒΆ added in v0.13.0
type MutationNotification struct {
Collection string `json:"collection"`
Event string `json:"event"`
RecordIDs []string `json:"record_ids"`
Records json.RawMessage `json:"records,omitempty"`
Timestamp string `json:"timestamp"`
}
MutationNotification represents a subscription event from collection changes.
type ParameterDefinition ΒΆ added in v0.4.0
type ParameterDefinition struct {
Required bool `json:"required"`
Default interface{} `json:"default,omitempty"`
Description string `json:"description,omitempty"`
}
ParameterDefinition for function parameters
type Query ΒΆ
type Query struct {
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
Filter map[string]interface{} `json:"filter,omitempty"`
}
Query represents a query for finding records
type QueryBuilder ΒΆ
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder provides a fluent API for building complex queries
func NewQueryBuilder ΒΆ
func NewQueryBuilder() *QueryBuilder
NewQueryBuilder creates a new QueryBuilder
func (*QueryBuilder) And ΒΆ
func (qb *QueryBuilder) And(conditions []map[string]interface{}) *QueryBuilder
And combines filters with AND logic
func (*QueryBuilder) Build ΒΆ
func (qb *QueryBuilder) Build() map[string]interface{}
Build builds the final query map
func (*QueryBuilder) BuildJSON ΒΆ
func (qb *QueryBuilder) BuildJSON() ([]byte, error)
BuildJSON builds the final query as JSON bytes
func (*QueryBuilder) BypassCache ΒΆ
func (qb *QueryBuilder) BypassCache(bypass bool) *QueryBuilder
BypassCache bypasses cache for this query
func (*QueryBuilder) BypassRipple ΒΆ
func (qb *QueryBuilder) BypassRipple(bypass bool) *QueryBuilder
BypassRipple bypasses ripple for this query
func (*QueryBuilder) Contains ΒΆ
func (qb *QueryBuilder) Contains(field string, substring string) *QueryBuilder
Contains adds a contains filter (substring match)
func (*QueryBuilder) EndsWith ΒΆ
func (qb *QueryBuilder) EndsWith(field string, suffix string) *QueryBuilder
EndsWith adds an ends-with filter
func (*QueryBuilder) Eq ΒΆ
func (qb *QueryBuilder) Eq(field string, value interface{}) *QueryBuilder
Eq adds an equality filter (Eq operator)
func (*QueryBuilder) ExcludeFields ΒΆ added in v0.9.0
func (qb *QueryBuilder) ExcludeFields(fields ...string) *QueryBuilder
ExcludeFields specifies which fields to exclude from results. All fields except these will be included in results. When used with SelectFields, exclude removes fields from the selected set.
func (*QueryBuilder) Gt ΒΆ
func (qb *QueryBuilder) Gt(field string, value interface{}) *QueryBuilder
Gt adds a greater-than filter (Gt operator)
func (*QueryBuilder) Gte ΒΆ
func (qb *QueryBuilder) Gte(field string, value interface{}) *QueryBuilder
Gte adds a greater-than-or-equal filter (Gte operator)
func (*QueryBuilder) In ΒΆ
func (qb *QueryBuilder) In(field string, values []interface{}) *QueryBuilder
In adds an in-array filter (In operator)
func (*QueryBuilder) Join ΒΆ
func (qb *QueryBuilder) Join(joinConfig map[string]interface{}) *QueryBuilder
Join adds a join configuration
func (*QueryBuilder) Limit ΒΆ
func (qb *QueryBuilder) Limit(limit int) *QueryBuilder
Limit sets the maximum number of results
func (*QueryBuilder) Lt ΒΆ
func (qb *QueryBuilder) Lt(field string, value interface{}) *QueryBuilder
Lt adds a less-than filter (Lt operator)
func (*QueryBuilder) Lte ΒΆ
func (qb *QueryBuilder) Lte(field string, value interface{}) *QueryBuilder
Lte adds a less-than-or-equal filter (Lte operator)
func (*QueryBuilder) Ne ΒΆ
func (qb *QueryBuilder) Ne(field string, value interface{}) *QueryBuilder
Ne adds a not-equal filter (Ne operator)
func (*QueryBuilder) Nin ΒΆ
func (qb *QueryBuilder) Nin(field string, values []interface{}) *QueryBuilder
Nin adds a not-in-array filter (NotIn operator)
func (*QueryBuilder) Not ΒΆ
func (qb *QueryBuilder) Not(condition map[string]interface{}) *QueryBuilder
Not negates a filter
func (*QueryBuilder) Or ΒΆ
func (qb *QueryBuilder) Or(conditions []map[string]interface{}) *QueryBuilder
Or combines filters with OR logic
func (*QueryBuilder) Page ΒΆ
func (qb *QueryBuilder) Page(page, pageSize int) *QueryBuilder
Page sets the page number and page size (convenience method).
Page numbers are 1-indexed: page 1 is the first page. Values below 1 are treated as page 1 (unlike Client.Paginate, which returns an error for page < 1). The offset calculation matches Client.Paginate.
func (*QueryBuilder) SelectFields ΒΆ added in v0.9.0
func (qb *QueryBuilder) SelectFields(fields ...string) *QueryBuilder
SelectFields specifies which fields to return (projection). Only these fields will be included in results (plus 'id' which is always included). When used with ExcludeFields, select is applied first, then exclude removes fields from the selected set (useful for nested fields like "metadata.internal").
func (*QueryBuilder) Skip ΒΆ
func (qb *QueryBuilder) Skip(skip int) *QueryBuilder
Skip sets the number of results to skip (for pagination)
func (*QueryBuilder) SortAscending ΒΆ
func (qb *QueryBuilder) SortAscending(field string) *QueryBuilder
SortAscending adds a sort field in ascending order
func (*QueryBuilder) SortDescending ΒΆ
func (qb *QueryBuilder) SortDescending(field string) *QueryBuilder
SortDescending adds a sort field in descending order
func (*QueryBuilder) StartsWith ΒΆ
func (qb *QueryBuilder) StartsWith(field string, prefix string) *QueryBuilder
StartsWith adds a starts-with filter
type QueryOptions ΒΆ added in v0.15.1
type QueryOptions struct {
Filter interface{} `json:"filter,omitempty"`
Sort interface{} `json:"sort,omitempty"`
Limit int `json:"limit,omitempty"`
Skip int `json:"skip,omitempty"`
}
QueryOptions are optional parameters for WS Query.
type RateLimitError ΒΆ
RateLimitError represents a rate limit error
func (*RateLimitError) Error ΒΆ
func (e *RateLimitError) Error() string
type RateLimitInfo ΒΆ
type RateLimitInfo struct {
Limit int // Maximum requests allowed per window
Remaining int // Requests remaining in current window
Reset int64 // Unix timestamp when the rate limit resets
}
RateLimitInfo contains rate limit information from the server
func (*RateLimitInfo) IsExceeded ΒΆ
func (r *RateLimitInfo) IsExceeded() bool
IsExceeded checks if the rate limit has been exceeded
func (*RateLimitInfo) IsNearLimit ΒΆ
func (r *RateLimitInfo) IsNearLimit() bool
IsNearLimit checks if approaching rate limit (less than 10% remaining)
func (*RateLimitInfo) RemainingPercentage ΒΆ
func (r *RateLimitInfo) RemainingPercentage() float64
RemainingPercentage returns the percentage of requests remaining
type RawCompletionRequest ΒΆ added in v0.13.0
type RawCompletionRequest struct {
SystemPrompt string `json:"system_prompt"`
Message string `json:"message"`
Provider *string `json:"provider,omitempty"`
Model *string `json:"model,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
}
RawCompletionRequest is the request body for POST /api/chat/complete. Stateless raw LLM completion β no session, no history, no RAG.
type RawCompletionResponse ΒΆ added in v0.13.0
type RawCompletionResponse struct {
Content string `json:"content"`
}
RawCompletionResponse is returned by RawCompletion.
type SSESubscription ΒΆ added in v0.16.0
type SSESubscription struct {
// Events receives mutation notifications. Closed when the stream ends.
Events <-chan MutationNotification
// Err receives at most one error if the stream terminates abnormally
// (scanner failure, context cancellation). Nil on clean EOF. Closed after send.
Err <-chan error
}
SSESubscription holds the channels returned by SubscribeSSE.
type Schema ΒΆ
type Schema struct {
Fields map[string]FieldTypeSchema `json:"fields"`
Version *int `json:"version,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
LastModified *string `json:"last_modified,omitempty"`
BypassRipple *bool `json:"bypass_ripple,omitempty"`
}
Schema represents a collection schema
type SchemaBuilder ΒΆ
type SchemaBuilder struct {
// contains filtered or unexported fields
}
SchemaBuilder provides a fluent API for building collection schemas
func NewSchemaBuilder ΒΆ
func NewSchemaBuilder() *SchemaBuilder
NewSchemaBuilder creates a new SchemaBuilder
func (*SchemaBuilder) AddField ΒΆ
func (sb *SchemaBuilder) AddField(name string, field FieldTypeSchema) *SchemaBuilder
AddField adds a field to the schema
func (*SchemaBuilder) Build ΒΆ
func (sb *SchemaBuilder) Build() Schema
Build builds the final Schema
func (*SchemaBuilder) BypassRipple ΒΆ
func (sb *SchemaBuilder) BypassRipple(bypass bool) *SchemaBuilder
BypassRipple sets bypass_ripple flag
func (*SchemaBuilder) Version ΒΆ
func (sb *SchemaBuilder) Version(version int) *SchemaBuilder
Version sets schema version
type SchemaCache ΒΆ added in v0.15.1
type SchemaCache struct {
// contains filtered or unexported fields
}
SchemaCache is an opt-in in-memory LRU cache for collection schema metadata.
func NewDisabledSchemaCache ΒΆ added in v0.15.1
func NewDisabledSchemaCache() *SchemaCache
NewDisabledSchemaCache creates a cache instance that is disabled by default.
func NewSchemaCache ΒΆ added in v0.15.1
func NewSchemaCache(config SchemaCacheConfig) *SchemaCache
NewSchemaCache creates a new schema cache with the given config.
func (*SchemaCache) ExtractRecordID ΒΆ added in v0.15.1
func (sc *SchemaCache) ExtractRecordID(collection string, record map[string]interface{}) string
ExtractRecordID extracts the record ID from a map, trying the schema cache alias first, then common fallbacks ("id", "_id").
func (*SchemaCache) Get ΒΆ added in v0.15.1
func (sc *SchemaCache) Get(collection string) *CachedSchema
Get returns the full cached schema entry, or nil if not cached/stale.
func (*SchemaCache) GetAlias ΒΆ added in v0.15.1
func (sc *SchemaCache) GetAlias(collection string) string
GetAlias returns the cached primary_key_alias for a collection, or "" if not cached/stale.
func (*SchemaCache) HandleSchemaChanged ΒΆ added in v0.15.1
func (sc *SchemaCache) HandleSchemaChanged(collection string, version uint64, primaryKeyAlias string)
HandleSchemaChanged processes a SchemaChanged event from the server. Updates the cache if the event version is newer.
func (*SchemaCache) Insert ΒΆ added in v0.15.1
func (sc *SchemaCache) Insert(collection, primaryKeyAlias string, version uint64)
Insert adds or updates a cached schema entry.
func (*SchemaCache) Invalidate ΒΆ added in v0.15.1
func (sc *SchemaCache) Invalidate(collection string)
Invalidate removes the cached schema for a collection.
func (*SchemaCache) InvalidateAll ΒΆ added in v0.15.1
func (sc *SchemaCache) InvalidateAll()
InvalidateAll clears the entire cache.
func (*SchemaCache) IsEnabled ΒΆ added in v0.15.1
func (sc *SchemaCache) IsEnabled() bool
IsEnabled returns whether the cache is enabled.
func (*SchemaCache) Len ΒΆ added in v0.15.1
func (sc *SchemaCache) Len() int
Len returns the number of cached entries.
func (*SchemaCache) SetEnabled ΒΆ added in v0.15.1
func (sc *SchemaCache) SetEnabled(enabled bool)
SetEnabled enables or disables the cache at runtime.
type SchemaCacheConfig ΒΆ added in v0.15.1
SchemaCacheConfig configures the schema cache.
type SearchQuery ΒΆ
type SearchQuery struct {
Query string `json:"query"`
// Full-text search parameters
Language *string `json:"language,omitempty"`
CaseSensitive *bool `json:"case_sensitive,omitempty"`
Fuzzy *bool `json:"fuzzy,omitempty"`
MinScore *float64 `json:"min_score,omitempty"`
Fields *string `json:"fields,omitempty"`
Weights *string `json:"weights,omitempty"`
EnableStemming *bool `json:"enable_stemming,omitempty"`
BoostExact *bool `json:"boost_exact,omitempty"`
MaxEditDistance *int `json:"max_edit_distance,omitempty"`
// Vector search parameters
Vector []float64 `json:"vector,omitempty"`
VectorField *string `json:"vector_field,omitempty"`
VectorMetric *string `json:"vector_metric,omitempty"`
VectorK *int `json:"vector_k,omitempty"`
VectorThreshold *float64 `json:"vector_threshold,omitempty"`
// Hybrid search parameters
TextWeight *float64 `json:"text_weight,omitempty"`
VectorWeight *float64 `json:"vector_weight,omitempty"`
// Performance flags
BypassRipple *bool `json:"bypass_ripple,omitempty"`
BypassCache *bool `json:"bypass_cache,omitempty"`
Limit *int `json:"limit,omitempty"`
// Field projection
SelectFields []string `json:"select_fields,omitempty"`
ExcludeFields []string `json:"exclude_fields,omitempty"`
// Metadata pre-filter for text, vector, and hybrid search. Carries a
// canonical QueryExpression whose shape matches the value under
// QueryBuilder.Build()'s "filter" key; note this struct serializes it under
// the JSON key "filters". Only records matching the filter are considered
// candidates before ranking.
Filters interface{} `json:"filters,omitempty"`
}
SearchQuery represents a search query for full-text and vector search
type SearchQueryBuilder ΒΆ
type SearchQueryBuilder struct {
// contains filtered or unexported fields
}
SearchQueryBuilder provides a fluent API for building search queries
func NewSearchQueryBuilder ΒΆ
func NewSearchQueryBuilder(queryString string) *SearchQueryBuilder
NewSearchQueryBuilder creates a new SearchQueryBuilder
func (*SearchQueryBuilder) BoostExact ΒΆ
func (sb *SearchQueryBuilder) BoostExact(enabled bool) *SearchQueryBuilder
BoostExact boosts exact matches
func (*SearchQueryBuilder) Build ΒΆ
func (sb *SearchQueryBuilder) Build() SearchQuery
Build builds the final SearchQuery
func (*SearchQueryBuilder) BypassCache ΒΆ
func (sb *SearchQueryBuilder) BypassCache(bypass bool) *SearchQueryBuilder
BypassCache bypasses cache
func (*SearchQueryBuilder) BypassRipple ΒΆ
func (sb *SearchQueryBuilder) BypassRipple(bypass bool) *SearchQueryBuilder
BypassRipple bypasses ripple cache
func (*SearchQueryBuilder) CaseSensitive ΒΆ
func (sb *SearchQueryBuilder) CaseSensitive(enabled bool) *SearchQueryBuilder
CaseSensitive enables case-sensitive search
func (*SearchQueryBuilder) EnableStemming ΒΆ
func (sb *SearchQueryBuilder) EnableStemming(enabled bool) *SearchQueryBuilder
EnableStemming enables stemming
func (*SearchQueryBuilder) ExcludeFields ΒΆ added in v0.8.0
func (sb *SearchQueryBuilder) ExcludeFields(fields []string) *SearchQueryBuilder
ExcludeFields excludes specific fields from results
func (*SearchQueryBuilder) Fields ΒΆ
func (sb *SearchQueryBuilder) Fields(fields string) *SearchQueryBuilder
Fields sets fields to search in (comma-separated)
func (*SearchQueryBuilder) Filters ΒΆ added in v0.22.0
func (sb *SearchQueryBuilder) Filters(filter interface{}) *SearchQueryBuilder
Filters sets a metadata pre-filter for text, vector, and hybrid search. Accepts a canonical QueryExpression whose shape matches the value under the "filter" key produced by QueryBuilder.Build() (the request serializes it under the "filters" key); only records matching the filter are considered as candidates before ranking.
func (*SearchQueryBuilder) Fuzzy ΒΆ
func (sb *SearchQueryBuilder) Fuzzy(enabled bool) *SearchQueryBuilder
Fuzzy enables fuzzy matching
func (*SearchQueryBuilder) Language ΒΆ
func (sb *SearchQueryBuilder) Language(language string) *SearchQueryBuilder
Language sets the language for stemming
func (*SearchQueryBuilder) Limit ΒΆ
func (sb *SearchQueryBuilder) Limit(limit int) *SearchQueryBuilder
Limit sets maximum number of results to return
func (*SearchQueryBuilder) MaxEditDistance ΒΆ
func (sb *SearchQueryBuilder) MaxEditDistance(distance int) *SearchQueryBuilder
MaxEditDistance sets maximum edit distance for fuzzy matching
func (*SearchQueryBuilder) MinScore ΒΆ
func (sb *SearchQueryBuilder) MinScore(score float64) *SearchQueryBuilder
MinScore sets minimum score threshold
func (*SearchQueryBuilder) SelectFields ΒΆ added in v0.8.0
func (sb *SearchQueryBuilder) SelectFields(fields []string) *SearchQueryBuilder
SelectFields selects specific fields to return
func (*SearchQueryBuilder) TextWeight ΒΆ
func (sb *SearchQueryBuilder) TextWeight(weight float64) *SearchQueryBuilder
TextWeight sets text search weight for hybrid search
func (*SearchQueryBuilder) Vector ΒΆ
func (sb *SearchQueryBuilder) Vector(vector []float64) *SearchQueryBuilder
Vector sets query vector for semantic search
func (*SearchQueryBuilder) VectorField ΒΆ
func (sb *SearchQueryBuilder) VectorField(field string) *SearchQueryBuilder
VectorField sets vector field name
func (*SearchQueryBuilder) VectorK ΒΆ
func (sb *SearchQueryBuilder) VectorK(k int) *SearchQueryBuilder
VectorK sets number of vector results (k-nearest neighbors)
func (*SearchQueryBuilder) VectorMetric ΒΆ
func (sb *SearchQueryBuilder) VectorMetric(metric string) *SearchQueryBuilder
VectorMetric sets vector similarity metric
func (*SearchQueryBuilder) VectorThreshold ΒΆ
func (sb *SearchQueryBuilder) VectorThreshold(threshold float64) *SearchQueryBuilder
VectorThreshold sets minimum similarity threshold
func (*SearchQueryBuilder) VectorWeight ΒΆ
func (sb *SearchQueryBuilder) VectorWeight(weight float64) *SearchQueryBuilder
VectorWeight sets vector search weight for hybrid search
func (*SearchQueryBuilder) Weights ΒΆ
func (sb *SearchQueryBuilder) Weights(weights string) *SearchQueryBuilder
Weights sets field weights (format: "field1:2.0,field2:1.5")
type SearchResponse ΒΆ
type SearchResponse struct {
Results []SearchResult `json:"results"`
Total int `json:"total"`
TookMs *int `json:"took_ms,omitempty"`
}
SearchResponse represents the response from a search query
type SearchResult ΒΆ
type SearchResult struct {
Record map[string]interface{} `json:"record"`
Score float64 `json:"score"`
MatchedFields []string `json:"matched_fields"`
}
SearchResult represents a single search result
type SerializationFormat ΒΆ added in v0.2.0
type SerializationFormat int
SerializationFormat represents the serialization format for client-server communication
const ( // MessagePack format (binary, 2-3x faster) - DEFAULT for best performance MessagePack SerializationFormat = iota // JSON format (human-readable, opt-in for debugging) JSON )
type SortFieldConfig ΒΆ added in v0.4.0
SortFieldConfig for Sort stage
type StageStats ΒΆ added in v0.4.0
type StageStats struct {
Stage string `json:"stage"`
InputCount int `json:"input_count"`
OutputCount int `json:"output_count"`
ExecutionTimeMs int64 `json:"execution_time_ms"`
}
StageStats contains statistics for a single stage
type SubscribeOptions ΒΆ added in v0.13.0
type SubscribeOptions struct {
FilterField string `json:"filter_field,omitempty"`
FilterValue string `json:"filter_value,omitempty"`
}
SubscribeOptions are optional parameters for Subscribe.
type SubscribeSSEOptions ΒΆ added in v0.16.0
SubscribeSSEOptions are optional parameters for SubscribeSSE.
type TokenUsage ΒΆ
type TokenUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}
TokenUsage represents token usage statistics
type ToolChoice ΒΆ added in v0.12.0
type ToolChoice struct {
Type string `json:"type"` // "auto", "none", "required", "tool"
Name string `json:"name,omitempty"` // Only used when Type is "tool"
}
ToolChoice controls how the LLM decides whether to use tools
type ToolConfig ΒΆ added in v0.12.0
type ToolConfig struct {
Enabled bool `json:"enabled"`
AllowedTools []string `json:"allowed_tools,omitempty"`
AllowedCollections []string `json:"allowed_collections,omitempty"`
MaxIterations *int `json:"max_iterations,omitempty"`
AllowWriteOperations *bool `json:"allow_write_operations,omitempty"`
ToolChoice *ToolChoice `json:"tool_choice,omitempty"`
}
ToolConfig configures which tools are available in a chat session
type TotpOptions ΒΆ added in v0.18.0
type TotpOptions struct {
Digits *int // 6 or 8; nil = server default (6)
Period *uint64 // seconds; nil = server default (30)
Algorithm string // "sha1" (default), "sha256", "sha512"; "" = default
Skew *uint8 // Β± steps for verify; nil = server default (1)
}
TotpOptions carries the optional fields for TOTP stages.
type UpdateAction ΒΆ added in v0.6.0
type UpdateAction string
UpdateAction represents valid actions for StageUpdateWithAction
const ( // UpdateActionPush appends a value to an array field UpdateActionPush UpdateAction = "push" // UpdateActionPop removes the last element from an array field UpdateActionPop UpdateAction = "pop" // UpdateActionIncrement adds a numeric value to a field UpdateActionIncrement UpdateAction = "increment" // UpdateActionDecrement subtracts a numeric value from a field UpdateActionDecrement UpdateAction = "decrement" // UpdateActionRemove removes a specific value from an array field UpdateActionRemove UpdateAction = "remove" )
type UpdateOptions ΒΆ added in v0.8.0
type UpdateOptions struct {
BypassRipple *bool
TransactionId *string
BypassCache *bool
SelectFields []string
ExcludeFields []string
}
UpdateOptions contains optional parameters for Update
type UpdateSessionRequest ΒΆ
type UpdateSessionRequest struct {
SystemPrompt *string `json:"system_prompt,omitempty"`
LLMModel *string `json:"llm_model,omitempty"`
Collections []CollectionConfig `json:"collections,omitempty"`
MaxContextMessages *int `json:"max_context_messages,omitempty"`
BypassRipple *bool `json:"bypass_ripple,omitempty"`
Title *string `json:"title,omitempty"`
Memory interface{} `json:"memory,omitempty"`
}
UpdateSessionRequest represents a request to update session metadata
type UpdateWithActionBody ΒΆ added in v0.13.0
type UpdateWithActionBody struct {
Field string `json:"field"`
Value interface{} `json:"value"`
}
UpdateWithActionBody is the request body for a single atomic field action.
type UpsertOptions ΒΆ added in v0.8.0
UpsertOptions contains optional parameters for Upsert
type UserFunction ΒΆ added in v0.11.0
type UserFunction struct {
Label string `json:"label"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Version *string `json:"version,omitempty"`
Parameters map[string]ParameterDefinition `json:"parameters"`
Functions []FunctionStageConfig `json:"functions"`
Tags []string `json:"tags,omitempty"`
HTTPMethod *string `json:"http_method,omitempty"`
HTTPPath *string `json:"http_path,omitempty"`
ID *string `json:"id,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
UserFunction is a reusable sequence of Functions stored in ekoDB. Called by label via the call_function chat tool or REST API.
type VectorIndexAlgorithm ΒΆ
type VectorIndexAlgorithm string
VectorIndexAlgorithm represents the vector index algorithm
const ( // VectorIndexFlat represents simple flat index (brute force) VectorIndexFlat VectorIndexAlgorithm = "flat" // VectorIndexHNSW represents Hierarchical Navigable Small World VectorIndexHNSW VectorIndexAlgorithm = "hnsw" // VectorIndexIVF represents Inverted File Index VectorIndexIVF VectorIndexAlgorithm = "ivf" )
type WebSocketClient ΒΆ
type WebSocketClient struct {
// contains filtered or unexported fields
}
WebSocketClient represents a WebSocket connection to ekoDB with full dispatcher.
func (*WebSocketClient) BatchDelete ΒΆ added in v0.15.1
func (ws *WebSocketClient) BatchDelete(collection string, ids []string, bypassRipple ...bool) error
BatchDelete deletes multiple records by IDs via WebSocket.
func (*WebSocketClient) BatchInsert ΒΆ added in v0.15.1
func (ws *WebSocketClient) BatchInsert(collection string, records []map[string]interface{}, bypassRipple ...bool) (json.RawMessage, error)
BatchInsert inserts multiple records at once via WebSocket.
func (*WebSocketClient) BatchUpdate ΒΆ added in v0.15.1
func (ws *WebSocketClient) BatchUpdate(collection string, updates [][2]interface{}, bypassRipple ...bool) (json.RawMessage, error)
BatchUpdate updates multiple records at once via WebSocket. Each update is a [id, data] pair.
func (*WebSocketClient) CancelChat ΒΆ added in v0.18.1
func (ws *WebSocketClient) CancelChat(chatID string) error
CancelChat aborts an in-flight chat stream by chat_id. The server fires the matching CancellationToken, drops the LLM HTTP call, and skips persisting the assistant message. Pre-fix on the Rust client side, dropping the stream channel only halted local chunk delivery β the LLM kept generating server-side and the "cancelled" turn still landed in /history. The Go client never had that bug because there was no cancel API at all; this method closes the gap.
Connection: requires an active WS (caller must have already called ChatSend or another method that establishes the connection). The cancel itself is idempotent on the server β sending it for a chat_id with no in-flight stream is a no-op and does not error.
func (*WebSocketClient) ChatSend ΒΆ added in v0.13.0
func (ws *WebSocketClient) ChatSend(chatID, message string, opts ...ChatSendOptions) (<-chan ChatStreamEvent, error)
ChatSend sends a chat message and returns a channel of streaming events. The channel is closed when the stream ends or errors.
func (*WebSocketClient) Close ΒΆ
func (ws *WebSocketClient) Close() error
Close closes the WebSocket connection and cleans up resources. It marks the client as closing FIRST so any in-flight reconnect loop exits cleanly and the dispatcher does not treat the resulting read error as a transient drop.
func (*WebSocketClient) CreateCollection ΒΆ added in v0.15.1
func (ws *WebSocketClient) CreateCollection(name string, schema ...interface{}) error
CreateCollection creates a new collection with optional schema via WebSocket.
func (*WebSocketClient) Delete ΒΆ added in v0.15.1
func (ws *WebSocketClient) Delete(collection, id string, bypassRipple ...bool) error
Delete deletes a record by ID via WebSocket.
func (*WebSocketClient) DeleteCollection ΒΆ added in v0.15.1
func (ws *WebSocketClient) DeleteCollection(name string) error
DeleteCollection deletes a collection via WebSocket.
func (*WebSocketClient) DistinctValues ΒΆ added in v0.15.1
func (ws *WebSocketClient) DistinctValues(collection, field string, filter ...interface{}) (json.RawMessage, error)
DistinctValues returns distinct values for a field via WebSocket.
func (*WebSocketClient) FindAll ΒΆ
func (ws *WebSocketClient) FindAll(collection string) ([]Record, error)
FindAll finds all records in a collection via WebSocket.
func (*WebSocketClient) FindByID ΒΆ added in v0.15.1
func (ws *WebSocketClient) FindByID(collection, id string) (json.RawMessage, error)
FindByID finds a single record by ID via WebSocket.
func (*WebSocketClient) Insert ΒΆ added in v0.15.1
func (ws *WebSocketClient) Insert(collection string, record map[string]interface{}, bypassRipple ...bool) (json.RawMessage, error)
Insert inserts a single record into a collection via WebSocket.
func (*WebSocketClient) ListCollections ΒΆ added in v0.15.1
func (ws *WebSocketClient) ListCollections() ([]string, error)
ListCollections lists all collections via WebSocket.
func (*WebSocketClient) Query ΒΆ added in v0.15.1
func (ws *WebSocketClient) Query(collection string, opts ...QueryOptions) (json.RawMessage, error)
Query queries records from a collection via WebSocket.
func (*WebSocketClient) RawCompletion ΒΆ added in v0.14.0
func (ws *WebSocketClient) RawCompletion(request RawCompletionRequest) (*RawCompletionResponse, error)
RawCompletion performs a stateless raw LLM completion via WebSocket.
Sends a RawComplete message and waits for the Success response. Preferred over HTTP for deployed instances: the persistent WSS connection is already authenticated and won't be killed by reverse proxy timeouts.
func (*WebSocketClient) RegisterClientTools ΒΆ added in v0.13.0
func (ws *WebSocketClient) RegisterClientTools(chatID string, tools []ClientToolDefinition) error
RegisterClientTools registers client-side tool definitions for a chat session.
func (*WebSocketClient) SendToolResult ΒΆ added in v0.13.0
func (ws *WebSocketClient) SendToolResult(chatID, callID string, success bool, result interface{}, errMsg string) error
SendToolResult sends a tool result back to the server during a chat stream.
func (*WebSocketClient) SetSchemaCache ΒΆ added in v0.15.1
func (ws *WebSocketClient) SetSchemaCache(cache *SchemaCache)
SetSchemaCache attaches a schema cache for automatic invalidation on SchemaChanged events.
func (*WebSocketClient) Subscribe ΒΆ added in v0.13.0
func (ws *WebSocketClient) Subscribe(collection string, opts ...SubscribeOptions) (<-chan MutationNotification, error)
Subscribe subscribes to mutation notifications on a collection. Returns a channel that receives MutationNotification events.
func (*WebSocketClient) TextSearch ΒΆ added in v0.15.1
func (ws *WebSocketClient) TextSearch(collection, query string, fields []string, limit int) (json.RawMessage, error)
TextSearch performs full-text search via WebSocket.
func (*WebSocketClient) Unsubscribe ΒΆ added in v0.20.0
func (ws *WebSocketClient) Unsubscribe(collection string)
Unsubscribe stops delivery for a collection: it sends a best-effort Unsubscribe frame to the server (so the server stops streaming mutations for this collection on this connection), removes the local subscription so it is no longer replayed on reconnect, and closes its notification channel. It is safe to call for a collection that is not currently subscribed (no-op).
The server frame is best-effort: if the socket is already gone the local teardown is sufficient, since the server drops all subscriptions when the connection closes. A unique messageId is attached purely so the server can echo it on its ack: Unsubscribe registers no pending request, so the dispatcher finds no match and silently discards the ack. The id stops that unmatched ack from falling through to the single-pending-request heuristic and being misrouted to an unrelated in-flight request.
func (*WebSocketClient) Update ΒΆ added in v0.15.1
func (ws *WebSocketClient) Update(collection, id string, record map[string]interface{}, bypassRipple ...bool) (json.RawMessage, error)
Update updates a record by ID via WebSocket.
func (*WebSocketClient) UpdateWithAction ΒΆ added in v0.15.1
func (ws *WebSocketClient) UpdateWithAction(collection, id, action, field string, value ...interface{}) (json.RawMessage, error)
UpdateWithAction applies an atomic field action to a record via WebSocket.