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.
| Task | Runnable example |
|---|---|
| CRUD | client_simple_crud.ts |
| QueryBuilder | client_query_builder.ts |
| Joins | client_joins.ts |
| Schemas | client_schema.ts |
| TTL | client_document_ttl.ts |
| Transactions | client_transactions.ts |
| Stored Functions | client_functions.ts |
| Concurrency / Locks / RateLimits | client_concurrency_stages.ts |
| Chat / RAG | client_chat_basic.ts, rag_conversation_system.ts |
| Search | client_search.ts |
| WebSockets | client_websocket_subscribe.ts |
| Admin / Permissions | client_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
| Task | Call shape |
|---|---|
| Insert | await client.insert(collection, record, options?) |
| Find | await client.find(collection, query, options?) |
| Point read | await client.findById(collection, id, options?) |
| Merge update | await client.update(collection, id, fields, options?) |
| Delete | await client.delete(collection, id, options?) |
| Batch insert | await client.batchInsert(collection, records, options?) |
| Read / change schema | getSchema(collection) / updateSchemaConstraints(collection, constraints) |
| Save / call a function | saveUserFunction(definition) / callFunction(idOrLabel, params?) |
| Transactions | beginTransaction(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)andextractRecord(record)handle typed responses; specialized helpers includegetObjectValueandgetArrayValue. - Insert may return only the ID. Read the record by that ID when other server-applied fields are needed; this pin's
InsertOptionshas noreturnRecordproperty. - Put
ttlin 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; aCountoutput is atresult.records[0].<output_field>, not on every input row. - Operations on an existing transaction, including commit, are not automatically retried after failure. A
401can be sent once more after token refresh. Preserve the typed HTTP error and its status/body; classifyConflictversus legacyApplybefore starting a new transaction.
See transactions at this pin, record TTL and REST. Never treat every thrown error as an empty query.