Skip to content

Commit 3f1bb3b

Browse files
authored
Merge pull request #527 from tidesdb/ts-ref
refresh ts reference
2 parents 451b1e9 + dc5cb44 commit 3f1bb3b

1 file changed

Lines changed: 101 additions & 2 deletions

File tree

src/content/docs/reference/typescript.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,29 @@ if (cf.isCompacting()) {
698698
- Maintenance windows · Check if operations are running before triggering manual compaction
699699
- Monitoring · Track background operation status for observability
700700

701+
### Purge (Force Flush + Compaction)
702+
703+
Purge forces a full flush of the active memtable followed by aggressive compaction, blocking until all flush and compaction I/O has drained. Use it to reclaim space and collapse the LSM tree on demand -- for example before a backup, or after a large batch of deletes -- rather than waiting for background thresholds.
704+
705+
Purge a single column family:
706+
707+
```typescript
708+
const cf = db.getColumnFamily('my_cf');
709+
710+
cf.purgeColumnFamily(); // flush + aggressive compaction for this CF, waits for I/O to finish
711+
```
712+
713+
Purge every column family in the database:
714+
715+
```typescript
716+
db.purge(); // flush + aggressive compaction across all CFs, waits for queues to drain
717+
```
718+
719+
**Behavior**
720+
- Synchronous; blocks until all flush and compaction work has completed
721+
- `cf.purgeColumnFamily()` operates on one column family; `db.purge()` applies to all of them
722+
- Throws `TidesDBError` on failure (`db.purge()` reports the first non-zero error code encountered)
723+
701724
### Updating Runtime Configuration
702725

703726
Update runtime-safe configuration settings. Changes apply to new operations only.
@@ -1220,10 +1243,78 @@ if (stats.objectStoreEnabled) {
12201243
}
12211244
```
12221245

1223-
:::note[S3/MinIO Connector]
1224-
The filesystem connector is always available. For S3/MinIO support, TidesDB must be built with `-DTIDESDB_WITH_S3=ON`. The S3 connector is not exposed through the TypeScript binding -- use the C API directly for S3 configuration.
1246+
#### S3 / MinIO Connector
1247+
1248+
The S3-compatible connector (AWS S3, MinIO, and any S3 API-compatible store) is exposed through the TypeScript binding via the `objectStoreS3Config` option on `TidesDB.open()`. Provide an `S3Config` instead of `objectStoreFsPath`; the `objectStoreConfig` behavior options (cache sizing, WAL replication, replica mode, etc.) apply identically to both connectors.
1249+
1250+
```typescript
1251+
import { TidesDB } from 'tidesdb';
1252+
1253+
const db = TidesDB.open({
1254+
dbPath: './mydb',
1255+
objectStoreS3Config: {
1256+
endpoint: 's3.amazonaws.com',
1257+
bucket: 'my-tidesdb-bucket',
1258+
prefix: 'production/db1/',
1259+
accessKey: process.env.AWS_ACCESS_KEY_ID!,
1260+
secretKey: process.env.AWS_SECRET_ACCESS_KEY!,
1261+
region: 'us-east-1',
1262+
useSsl: true,
1263+
},
1264+
objectStoreConfig: {
1265+
localCacheMaxBytes: 512 * 1024 * 1024, // 512MB local cache
1266+
maxConcurrentUploads: 8,
1267+
},
1268+
});
1269+
1270+
db.close();
1271+
```
1272+
1273+
For MinIO (or any self-hosted S3 gateway), use path-style URLs and the gateway endpoint:
1274+
1275+
```typescript
1276+
const db = TidesDB.open({
1277+
dbPath: './mydb',
1278+
objectStoreS3Config: {
1279+
endpoint: 'minio.local:9000',
1280+
bucket: 'tidesdb',
1281+
accessKey: 'minioadmin',
1282+
secretKey: 'minioadmin',
1283+
useSsl: false,
1284+
usePathStyle: true, // required for MinIO
1285+
},
1286+
});
1287+
```
1288+
1289+
##### `S3Config` Options
1290+
1291+
| Field | Type | Default | Description |
1292+
|-------|------|---------|-------------|
1293+
| `endpoint` | `string` | *(required)* | S3 endpoint (e.g. `"s3.amazonaws.com"` or `"minio.local:9000"`) |
1294+
| `bucket` | `string` | *(required)* | Bucket name |
1295+
| `accessKey` | `string` | *(required)* | AWS access key ID |
1296+
| `secretKey` | `string` | *(required)* | AWS secret access key |
1297+
| `prefix` | `string \| null` | `null` | Key prefix (e.g. `"production/db1/"`) |
1298+
| `region` | `string \| null` | `null` | AWS region (e.g. `"us-east-1"`); `null` for MinIO |
1299+
| `useSsl` | `boolean` | `true` | Use HTTPS |
1300+
| `usePathStyle` | `boolean` | `false` | Use path-style URLs (required for MinIO); `false` = virtual-hosted (AWS) |
1301+
| `tlsCaPath` | `string \| null` | `null` (system bundle) | Custom CA bundle file path |
1302+
| `tlsInsecureSkipVerify` | `boolean` | `false` | Disable TLS peer + host verification (test only, insecure) |
1303+
| `multipartThreshold` | `number` | `0` (library default) | Object size at/above which multipart upload is used |
1304+
| `multipartPartSize` | `number` | `0` (library default) | Multipart chunk size in bytes |
1305+
1306+
:::note[S3 build requirement]
1307+
The filesystem connector is always available. The S3 connector requires a `libtidesdb` built with `-DTIDESDB_WITH_S3=ON`. On a library built without S3 support, passing `objectStoreS3Config` throws a `TidesDBError` explaining that the S3 connector is unavailable; rebuild with `TIDESDB_WITH_S3` to enable it.
12251308
:::
12261309

1310+
The `ObjStoreBackend` enum identifies which connector a database reports:
1311+
1312+
| Member | Value | Backend |
1313+
|--------|-------|---------|
1314+
| `ObjStoreBackend.Fs` | `0` | Filesystem connector |
1315+
| `ObjStoreBackend.S3` | `1` | S3-compatible connector |
1316+
| `ObjStoreBackend.Unknown` | `99` | Unknown / not set |
1317+
12271318
### Promote Replica to Primary
12281319

12291320
Switch a read-only replica database to primary mode.
@@ -1596,6 +1687,12 @@ db.createColumnFamily('sorted_cf', {
15961687
});
15971688
```
15981689

1690+
`registerComparator(name, ctxStr?)` accepts an optional second argument, a context string passed through to the comparator's context (default `""`). Use it to parameterize a comparator (for example, a collation locale) without a separate registration call:
1691+
1692+
```typescript
1693+
db.registerComparator('locale_aware', 'en_US');
1694+
```
1695+
15991696
### Retrieving a Registered Comparator
16001697

16011698
Use `getComparator` to check whether a comparator is registered:
@@ -1646,6 +1743,8 @@ import {
16461743
// Configuration interfaces
16471744
Config,
16481745
ColumnFamilyConfig,
1746+
ObjectStoreConfig,
1747+
S3Config,
16491748
Stats,
16501749
DbStats,
16511750
CacheStats,

0 commit comments

Comments
 (0)