# autessa.autessadb

Source: https://docs.autessa.com/docs/autessascript/sdk/autessadb

> AutessaDB tables, rows, queries, joins, triggers, access logs, Drives, and columnar tables.

# autessa.autessadb

AutessaDB tables, rows, queries, joins, triggers, access logs, Drives, and columnar tables.

Alongside single-row CRUD, this namespace covers **bulk writes** (`bulkInsert`,
`bulkUpdateByIds`, `bulkDeleteByIds` — many rows per call, with per-row results
and modes that control atomicity and whether triggers/indexing/computation run),
**aggregation** (`aggregate` — grouped `COUNT`/`SUM`/`AVG`/`MIN`/`MAX`), and
**keyset (cursor) pagination** on reads (`orderBy` plus a `cursor` from the prior
response's `nextCursor`, staying fast on large tables). See each method's
signature below for the exact request and response shapes.

Two table-shape options appear here as well. A table can be **append-only**
(immutable / audit-grade): rows can be inserted and read but never updated or
deleted, computed columns are not allowed, and column removal is blocked — the
setting is a one-way latch chosen at table creation, and each returned schema
carries an `appendOnly` flag. Columns can also be **indexed** for faster
equality filtering: `INTEGER`, `FLOAT`, `BOOLEAN`, `SINGLE_SELECT`, and
foreign-key columns are always indexed, `SHORT_TEXT` can opt in (its values are
length-capped to 2000 characters once indexed), and `LONG_TEXT` / `MULTI_SELECT`
/ media columns cannot be indexed. On a large table a newly requested index
builds in the background and becomes usable when its build finishes.

## Drives

`autessa.autessadb.drive` works with [Drives](/docs/guide/autessadb/drive.md), tables of files and folders. Calls take the Drive's `tableId` and absolute paths, run as the invoking user, and only reach the files and folders that user can open.

| Group | Methods |
| --- | --- |
| `drive` | `create`, `ls`, `tree`, `find`, `stat`, `grep`, `read`, `search`, `mkdir`, `move`, `trash`, `restore`, `purge`, `downloadUrl`, `status`, `usage`, `transferOwner` |
| `drive.uploads` | `create`, `partUrls`, `completeMultipart`, `commit`, `abort` |
| `drive.versions` | `list`, `restore` |
| `drive.shares` | `list`, `upsert`, `remove`, `sharedWithMe`, `whoHasAccess` |
| `drive.links` | `create`, `list`, `revoke` |

Listings and searches return `nextCursor` and `truncated`; pass the cursor back with the same arguments to continue. A `move` that would change who has access returns `requiresConfirmation` and moves nothing until you repeat it with `confirm: true`. Request and response shapes match the [Drive API](/docs/api/autessadb-drive.md).

```javascript
const DRIVE = "V1StGXR8Z5";

// Find a clause, then read the page it is on before quoting it.
const hits = autessa.autessadb.drive.grep({
  tableId: DRIVE,
  path: "/Shared/Legal/Contracts",
  pattern: "termination for convenience",
  caseInsensitive: true,
});

if (hits.ok && hits.data.matches.length > 0) {
  const m = hits.data.matches[0];
  const page = autessa.autessadb.drive.read({ tableId: DRIVE, id: m.id, pages: String(m.page) });
  console.log(`${m.path} p.${m.page} L.${m.pageLine}`, page.data.lines.map((l) => l.text).join("\n"));
}

// Share a folder with a team as Viewer.
autessa.autessadb.drive.shares.upsert({
  tableId: DRIVE,
  path: "/Shared/Legal",
  principals: [{ type: "TEAM", teamId: "3b1f6a2e-7c41-4d55-9a0e-58c2b7f1d903" }],
  role: "VIEWER",
});
```

Uploading from a script follows the same three steps as the API (`uploads.create`, send the bytes, `uploads.commit`); from a terminal, `autessa autessadb drive push` does all of it for a whole folder.

## Analytics tables

`autessa.autessadb.analytics` works with [columnar tables](/docs/guide/autessadb/analytics.md): columnar tables queried with read-only ANSI SQL (analytical functions such as `date_trunc`, `approx_distinct`, and `format_datetime` are available).

| Purpose | Methods |
| --- | --- |
| Tables | `create`, `inferSchema`, `describe`, `addColumns`, `updateSemantics`, `createAgentTools` |
| Data | `loadFromS3`, `loadFromTable`, `appendRows`, `preview` |
| Queries | `query`, `estimate`, `jobStatus`, `jobResults`, `jobDownloadUrl`, `cancel`, `jobs` |

Queries run asynchronously as jobs and typically take a few seconds. `query` waits up to `waitMs` (at most 20 seconds) and, if the job finished, returns the first rows in `preview`; otherwise poll `jobStatus` and page through `jobResults`. `DECIMAL` values and very large integers come back as strings, and timestamps as ISO-8601 UTC strings. Request and response shapes match the [AutessaDB - Columnar API](/docs/api/autessadb-analytics.md).

```javascript
const ORDERS = "V1StGXR8Z5";

let res = autessa.autessadb.analytics.query({
  tableId: ORDERS,
  sql: `SELECT region, SUM(net_amount) AS revenue
        FROM order_lines
        WHERE order_date >= DATE '2026-01-01'
        GROUP BY region`,
  waitMs: 20000,
});

let job = res.data;
while (job.state === "QUEUED" || job.state === "RUNNING") {
  job = autessa.autessadb.analytics.jobStatus({ tableId: ORDERS, jobId: job.jobId, waitMs: 20000 }).data;
}

if (job.state === "SUCCEEDED") {
  const page = autessa.autessadb.analytics.jobResults({ tableId: ORDERS, jobId: job.jobId, page: 0, pageSize: 1000 });
  page.data.rows.forEach((r) => console.log(r.region, r.revenue));
} else {
  console.log(job.error.errorCode, job.error.message, job.error.hint);
}
```

The analytics methods do not support row-level calls: `autessa.autessadb.query.*` on a columnar table fails with a message pointing to `autessa.autessadb.analytics.query`. On a Drive, write files through `drive.*` rather than `query.insert`, which cannot create files or folders.

## Related

- [Autessa SDK overview](/docs/autessascript/sdk.md)
- [AutessaDB Drive](/docs/guide/autessadb/drive.md) and the [Drive API](/docs/api/autessadb-drive.md)
- [Columnar tables](/docs/guide/autessadb/analytics.md) and the [AutessaDB - Columnar API](/docs/api/autessadb-analytics.md)

