Skip to main content

TypeScript SDK quick reference for agents

Baseline: @ekodb/ekodb-client 0.37.0, checked against its client implementation, CRUD example and query example. Install with npm install @ekodb/ekodb-client@0.37.0.

Runnable Examples (Check Before Guessing)​

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

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

Initialize and query​

The application supplies a base URL and scoped API key at runtime. This bounded read returns ordinary application values:

import { EkoDBClient, QueryBuilder, extractRecord } from "@ekodb/ekodb-client";

async function listActive(baseURL: string, apiKey: string) {
const client = new EkoDBClient(baseURL, apiKey);
await client.init();
const query = new QueryBuilder().eq("active", true).limit(25).build();
const records = await client.find("agent_tasks", query);
return records.map(record => extractRecord(record));
}

find returns an array directly. findById returns a record. The client exchanges and refreshes JWTs; do not perform a second, parallel authentication mechanism. Keep credentials out of conversation and logs.

Method map​

TaskCall shape
Insertawait client.insert(collection, record, options?)
Findawait client.find(collection, query, options?)
Point readawait client.findById(collection, id, options?)
Merge updateawait client.update(collection, id, fields, options?)
Deleteawait client.delete(collection, id, options?)
Batch insertawait client.batchInsert(collection, records, options?)
Read / change schemagetSchema(collection) / updateSchemaConstraints(collection, constraints)
Save / call a functionsaveUserFunction(definition) / callFunction(idOrLabel, params?)
TransactionsbeginTransaction(isolationLevel?), commitTransaction(id), rollbackTransaction(id)

Options use camelCase, such as transactionId, bypassRipple and selectFields. Raw query fields use the wire names, such as select_fields. Use the declared options type for the particular method. find with JoinBuilder supports joins; a stored-function Query step does not.

Values, TTL and failures​

  • Write plain nested objects, arrays and booleans. Use typed envelopes for ambiguous types, not as an application data shape. getValue(record.field) and extractRecord(record) handle typed responses; specialized helpers include getObjectValue and getArrayValue.
  • Insert may return only the ID. Read the record by that ID when other server-applied fields are needed; this pin's InsertOptions has no returnRecord property.
  • Put ttl in the record passed to insert/update, or in each record passed to batch insert. Omitting it on update preserves expiry. See canonical formats.
  • Function calls return a FunctionResult; a Count output is at result.records[0].<output_field>, not on every input row.
  • Operations on an existing transaction, including commit, are not automatically retried after failure. A 401 can be sent once more after token refresh. Preserve the typed HTTP error and its status/body; classify Conflict versus legacy Apply before starting a new transaction.

See transactions at this pin, record TTL and REST. Never treat every thrown error as an empty query.