Skip to content

Commit f48af2e

Browse files
docs: sync from coderbuzz/codex@b1e2bde
1 parent 0ed2507 commit f48af2e

2 files changed

Lines changed: 59 additions & 24 deletions

File tree

‎AI_KNOWLEDGE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- docs: sync from coderbuzz/codex@e9b6bce -->
1+
<!-- docs: sync from coderbuzz/codex@b1e2bde -->
22

33
# @coderbuzz/sql — AI Expert Knowledge Reference
44

‎README.md‎

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- docs: sync from coderbuzz/codex@e9b6bce -->
1+
<!-- docs: sync from coderbuzz/codex@b1e2bde -->
22

33
# @coderbuzz/sql
44

@@ -617,9 +617,33 @@ const db = mssql.connect({ server: "localhost", port: 1433, database: "app", use
617617
const db = ch.connect({ url: "http://localhost:8123", database: "default", username: "default", password: "" });
618618
```
619619

620-
### Oracle, Snowflake, Databricks
620+
### Oracle
621621

622-
See the full API reference for connection config details.
622+
```ts
623+
const db = oracle.connect({
624+
user: "app", password: "secret",
625+
connectString: "localhost/XEPDB1", poolMax: 10,
626+
});
627+
```
628+
629+
### Snowflake
630+
631+
```ts
632+
const db = snowflake.connect({
633+
account: "my-account", username: "APP_USER", password: "secret",
634+
database: "APP_DB", schema: "PUBLIC", warehouse: "COMPUTE_WH", role: "APP_ROLE",
635+
});
636+
```
637+
638+
### Databricks
639+
640+
```ts
641+
const db = databricks.connect({
642+
host: "adb-xxxx.azuredatabricks.net",
643+
path: "/sql/1.0/warehouses/xxxx",
644+
token: "dapi...",
645+
});
646+
```
623647

624648
---
625649

@@ -643,28 +667,36 @@ See the full API reference for connection config details.
643667
### `Sql<T>` (Base Engine)
644668

645669
```ts
646-
db.use(middleware): this
647-
await db.execute(queryOrSql): Promise<T>
648-
await db.transaction(fn): Promise<R>
649-
await db.migrate(...tables): Promise<void>
650-
db.select(...fields): SelectQuery<T>
651-
db.select_distinct(...fields): SelectQuery<T>
652-
db.insert_into(table, options?): InsertQuery<T>
653-
db.batchInsert(table, options): InsertBatcher<T>
654-
db.update(table): UpdateQuery<T>
655-
db.delete_from(table): DeleteQuery<T>
656-
db.sql<R>(strings, ...values): RawQuery<R>
657-
db.dialect: string
658-
db.compiler: BaseCompiler
670+
db.use(middleware) // register middleware in the execution pipeline
671+
await db.execute(queryOrSql) // run SQL string or compiled query, return T
672+
await db.transaction(fn) // BEGIN → fn(tx) → COMMIT (auto ROLLBACK on error)
673+
await db.migrate(...tables) // CREATE TABLE IF NOT EXISTS + indexes for each table
674+
db.select(...fields) // start a SELECT query (untyped)
675+
db.select_distinct(...fields) // start a SELECT DISTINCT query
676+
db.insert_into(table, opts?) // start an INSERT query
677+
db.batchInsert(table, opts) // create an InsertBatcher<T>
678+
db.update(table) // start an UPDATE query
679+
db.delete_from(table) // start a DELETE query
680+
db.sql<R>(strings, ...values) // tagged template for safe raw SQL
681+
db.dialect // dialect name string (readonly)
682+
db.compiler // BaseCompiler instance (readonly)
659683
```
660684
661685
### `SqlTable<S>`
662686
663687
```ts
664-
table.tableName, table.columns, table.options
665-
table.toAst(), table.createTable(), table.createIndexes(), table.dropTable()
666-
table.from(engine), table.select(), table.insert(), table.update(), table.delete()
667-
table.bind(engine): BoundTable<S>
688+
table.tableName // table name string
689+
table.columns // column definitions (for type inference)
690+
table.options // table options (engine, orderBy, etc.)
691+
table.toAst() // produce AST for migration tools
692+
table.createTable(dialect?) // generate "CREATE TABLE ..." DDL
693+
table.createIndexes(dialect?) // generate "CREATE INDEX ..." DDL strings[]
694+
table.dropTable() // generate "DROP TABLE IF EXISTS ..."
695+
table.from(engine) // start a typed SELECT query
696+
table.insert(engine) // start a typed INSERT query
697+
table.update(engine) // start a typed UPDATE query
698+
table.delete(engine) // start a typed DELETE query
699+
table.bind(engine) // return BoundTable<S> (no-repeat-engine API)
668700
```
669701
670702
### `SelectQuery<T>`
@@ -674,9 +706,12 @@ Full chain: `.with()`, `.select()`, `.from()`, `.left_join()`, `.inner_join()`,
674706
### `InsertBatcher<T>`
675707
676708
```ts
677-
batcher.write(rowOrRows): void
678-
await batcher.flush(), await batcher.drain(), await batcher.close()
679-
batcher.pendingCount, batcher.inflightCount
709+
batcher.write(rowOrRows) // add rows to pending queue
710+
await batcher.flush() // manually flush pending rows
711+
await batcher.drain() // wait for in-flight flush requests
712+
await batcher.close() // flush + drain + seal (throws if write() after)
713+
batcher.pendingCount // rows waiting behind debounce timer
714+
batcher.inflightCount // flush requests currently executing
680715
```
681716
682717
---

0 commit comments

Comments
 (0)