@bunit/qb 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -88
- package/dist/dialects/_chunks/mysql-x4fwf4rk.mjs +3 -0
- package/dist/dialects/mysql.d.ts +7 -8
- package/dist/dialects/mysql.mjs +2 -25
- package/dist/dialects/postgres.d.ts +7 -8
- package/dist/dialects/postgres.mjs +2 -25
- package/dist/dialects/sqlite.d.ts +7 -8
- package/dist/dialects/sqlite.mjs +2 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
# @bunit/qb
|
|
2
|
-
|
|
3
|
-
> Kysely dialects powered by [Bun.SQL](https://bun.net.cn/docs/api/sql) for PostgreSQL, MySQL, and SQLite.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- ⚡️ **Native Bun.SQL** - Zero abstraction overhead using Bun's built-in SQL client
|
|
8
|
-
- 🔌 **Kysely Compatible** - Drop-in dialects with full type safety
|
|
9
|
-
- 🎯 **Multi-Database** - PostgreSQL, MySQL, MariaDB, and SQLite support
|
|
10
|
-
- 📦 **Zero Runtime Dependencies** - Only requires Kysely as peer dependency
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
bun add @bunit/qb kysely
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
### PostgreSQL
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Kysely } from "kysely";
|
|
24
|
-
import { PostgresDialect } from "@bunit/qb/dialects/postgres";
|
|
25
|
-
|
|
26
|
-
const db = new Kysely<Database>({
|
|
27
|
-
dialect: new PostgresDialect({
|
|
28
|
-
url: "postgres://user:pass@localhost:5432/mydb",
|
|
29
|
-
}),
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### MySQL
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { Kysely } from "kysely";
|
|
37
|
-
import { MySQLDialect } from "@bunit/qb/dialects/mysql";
|
|
38
|
-
|
|
39
|
-
const db = new Kysely<Database>({
|
|
40
|
-
dialect: new MySQLDialect({
|
|
41
|
-
url: "mysql://user:pass@localhost:3306/mydb",
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### SQLite
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import { Kysely } from "kysely";
|
|
50
|
-
import { SQLiteDialect } from "@bunit/qb/dialects/sqlite";
|
|
51
|
-
|
|
52
|
-
// File-based
|
|
53
|
-
const db = new Kysely<Database>({
|
|
54
|
-
dialect: new SQLiteDialect({
|
|
55
|
-
url: "sqlite://path/to/myapp.db",
|
|
56
|
-
}),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// In-memory
|
|
60
|
-
const memoryDb = new Kysely<Database>({
|
|
61
|
-
dialect: new SQLiteDialect({
|
|
62
|
-
url: ":memory:",
|
|
63
|
-
}),
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Advanced Configuration
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import { PostgresDialect } from "@bunit/qb/dialects/postgres";
|
|
71
|
-
|
|
72
|
-
const dialect = new PostgresDialect({
|
|
73
|
-
options: {
|
|
74
|
-
hostname: "localhost",
|
|
75
|
-
port: 5432,
|
|
76
|
-
database: "mydb",
|
|
77
|
-
username: "user",
|
|
78
|
-
password: "pass",
|
|
79
|
-
max: 20, // connection pool size
|
|
80
|
-
idleTimeout: 30,
|
|
81
|
-
tls: true,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## License
|
|
87
|
-
|
|
88
|
-
[MIT](../../LICENSE) © [Demo Macro](https://www.demomacro.com/)
|
|
1
|
+
# @bunit/qb
|
|
2
|
+
|
|
3
|
+
> Kysely dialects powered by [Bun.SQL](https://bun.net.cn/docs/api/sql) for PostgreSQL, MySQL, and SQLite.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ⚡️ **Native Bun.SQL** - Zero abstraction overhead using Bun's built-in SQL client
|
|
8
|
+
- 🔌 **Kysely Compatible** - Drop-in dialects with full type safety
|
|
9
|
+
- 🎯 **Multi-Database** - PostgreSQL, MySQL, MariaDB, and SQLite support
|
|
10
|
+
- 📦 **Zero Runtime Dependencies** - Only requires Kysely as peer dependency
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun add @bunit/qb kysely
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### PostgreSQL
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Kysely } from "kysely";
|
|
24
|
+
import { PostgresDialect } from "@bunit/qb/dialects/postgres";
|
|
25
|
+
|
|
26
|
+
const db = new Kysely<Database>({
|
|
27
|
+
dialect: new PostgresDialect({
|
|
28
|
+
url: "postgres://user:pass@localhost:5432/mydb",
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### MySQL
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Kysely } from "kysely";
|
|
37
|
+
import { MySQLDialect } from "@bunit/qb/dialects/mysql";
|
|
38
|
+
|
|
39
|
+
const db = new Kysely<Database>({
|
|
40
|
+
dialect: new MySQLDialect({
|
|
41
|
+
url: "mysql://user:pass@localhost:3306/mydb",
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### SQLite
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { Kysely } from "kysely";
|
|
50
|
+
import { SQLiteDialect } from "@bunit/qb/dialects/sqlite";
|
|
51
|
+
|
|
52
|
+
// File-based
|
|
53
|
+
const db = new Kysely<Database>({
|
|
54
|
+
dialect: new SQLiteDialect({
|
|
55
|
+
url: "sqlite://path/to/myapp.db",
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// In-memory
|
|
60
|
+
const memoryDb = new Kysely<Database>({
|
|
61
|
+
dialect: new SQLiteDialect({
|
|
62
|
+
url: ":memory:",
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Advanced Configuration
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { PostgresDialect } from "@bunit/qb/dialects/postgres";
|
|
71
|
+
|
|
72
|
+
const dialect = new PostgresDialect({
|
|
73
|
+
options: {
|
|
74
|
+
hostname: "localhost",
|
|
75
|
+
port: 5432,
|
|
76
|
+
database: "mydb",
|
|
77
|
+
username: "user",
|
|
78
|
+
password: "pass",
|
|
79
|
+
max: 20, // connection pool size
|
|
80
|
+
idleTimeout: 30,
|
|
81
|
+
tls: true,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
[MIT](../../LICENSE) © [Demo Macro](https://www.demomacro.com/)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{CompiledQuery as z}from"kysely";var{SQL:A}=globalThis.Bun;class E{#j;#h;constructor(h){this.#j=h}async init(){let{url:h,options:j}=this.#j;if(h)this.#h=new A(h,j??{});else if(j)this.#h=new A(j);else throw Error("Either url or options must be provided");await this.#h.connect()}async acquireConnection(){if(!this.#h)throw Error("Driver not initialized. Call init() first.");return new D(this.#h)}async beginTransaction(h,j){if(j.isolationLevel||j.accessMode){let v="start transaction";if(j.isolationLevel)v+=` isolation level ${j.isolationLevel}`;if(j.accessMode)v+=` ${j.accessMode}`;await h.executeQuery(z.raw(v))}else await h.executeQuery(z.raw("begin"))}async commitTransaction(h){await h.executeQuery(z.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(z.raw("rollback"))}async releaseConnection(h){}async destroy(){if(this.#h)await this.#h.end(),this.#h=void 0}}class D{#j;constructor(h){this.#j=h}async executeQuery(h){let{sql:j,parameters:v}=h,x=await this.#j.unsafe(j,[...v]);return{rows:Array.isArray(x)?x:x?[x]:[]}}streamQuery(h,j){throw Error("Streaming queries are not supported")}}
|
|
3
|
+
export{E as a};
|
package/dist/dialects/mysql.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Kysely, DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
|
|
2
2
|
import type { BunSQLDialectConfig } from "../types";
|
|
3
|
-
export interface MySQLDialectConfig extends BunSQLDialectConfig {
|
|
4
|
-
}
|
|
3
|
+
export interface MySQLDialectConfig extends BunSQLDialectConfig {}
|
|
5
4
|
export declare class MySQLDialect implements Dialect {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config?: MySQLDialectConfig);
|
|
7
|
+
createDriver(): Driver;
|
|
8
|
+
createQueryCompiler(): QueryCompiler;
|
|
9
|
+
createAdapter(): DialectAdapter;
|
|
10
|
+
createIntrospector(db: Kysely<any>): DatabaseIntrospector;
|
|
12
11
|
}
|
|
13
12
|
export default MySQLDialect;
|
package/dist/dialects/mysql.mjs
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export class MySQLDialect {
|
|
5
|
-
#config;
|
|
6
|
-
constructor(config = {}) {
|
|
7
|
-
this.#config = config;
|
|
8
|
-
}
|
|
9
|
-
createDriver() {
|
|
10
|
-
return new BunSQLDriver({
|
|
11
|
-
adapter: "mysql",
|
|
12
|
-
...this.#config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
createQueryCompiler() {
|
|
16
|
-
return new MysqlQueryCompiler;
|
|
17
|
-
}
|
|
18
|
-
createAdapter() {
|
|
19
|
-
return new MysqlAdapter;
|
|
20
|
-
}
|
|
21
|
-
createIntrospector(db) {
|
|
22
|
-
return new MysqlIntrospector(db);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export default MySQLDialect;
|
|
1
|
+
// @bun
|
|
2
|
+
import{a as r}from"./_chunks/mysql-x4fwf4rk.mjs";import{MysqlAdapter as o,MysqlIntrospector as i,MysqlQueryCompiler as a}from"kysely";class t{#e;constructor(e={}){this.#e=e}createDriver(){return new r({adapter:"mysql",...this.#e})}createQueryCompiler(){return new a}createAdapter(){return new o}createIntrospector(e){return new i(e)}}var c=t;export{c as default,t as MySQLDialect};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Kysely, DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
|
|
2
2
|
import type { BunSQLDialectConfig } from "../types";
|
|
3
|
-
export interface PostgresDialectConfig extends BunSQLDialectConfig {
|
|
4
|
-
}
|
|
3
|
+
export interface PostgresDialectConfig extends BunSQLDialectConfig {}
|
|
5
4
|
export declare class PostgresDialect implements Dialect {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config?: PostgresDialectConfig);
|
|
7
|
+
createDriver(): Driver;
|
|
8
|
+
createQueryCompiler(): QueryCompiler;
|
|
9
|
+
createAdapter(): DialectAdapter;
|
|
10
|
+
createIntrospector(db: Kysely<any>): DatabaseIntrospector;
|
|
12
11
|
}
|
|
13
12
|
export default PostgresDialect;
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export class PostgresDialect {
|
|
5
|
-
#config;
|
|
6
|
-
constructor(config = {}) {
|
|
7
|
-
this.#config = config;
|
|
8
|
-
}
|
|
9
|
-
createDriver() {
|
|
10
|
-
return new BunSQLDriver({
|
|
11
|
-
adapter: "postgres",
|
|
12
|
-
...this.#config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
createQueryCompiler() {
|
|
16
|
-
return new PostgresQueryCompiler;
|
|
17
|
-
}
|
|
18
|
-
createAdapter() {
|
|
19
|
-
return new PostgresAdapter;
|
|
20
|
-
}
|
|
21
|
-
createIntrospector(db) {
|
|
22
|
-
return new PostgresIntrospector(db);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export default PostgresDialect;
|
|
1
|
+
// @bun
|
|
2
|
+
import{a as r}from"./_chunks/mysql-x4fwf4rk.mjs";import{PostgresAdapter as o,PostgresIntrospector as i,PostgresQueryCompiler as s}from"kysely";class t{#e;constructor(e={}){this.#e=e}createDriver(){return new r({adapter:"postgres",...this.#e})}createQueryCompiler(){return new s}createAdapter(){return new o}createIntrospector(e){return new i(e)}}var c=t;export{c as default,t as PostgresDialect};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Kysely, DatabaseIntrospector, Dialect, DialectAdapter, Driver, QueryCompiler } from "kysely";
|
|
2
2
|
import type { BunSQLDialectConfig } from "../types";
|
|
3
|
-
export interface SQLiteDialectConfig extends BunSQLDialectConfig {
|
|
4
|
-
}
|
|
3
|
+
export interface SQLiteDialectConfig extends BunSQLDialectConfig {}
|
|
5
4
|
export declare class SQLiteDialect implements Dialect {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
#private;
|
|
6
|
+
constructor(config?: SQLiteDialectConfig);
|
|
7
|
+
createDriver(): Driver;
|
|
8
|
+
createQueryCompiler(): QueryCompiler;
|
|
9
|
+
createAdapter(): DialectAdapter;
|
|
10
|
+
createIntrospector(db: Kysely<any>): DatabaseIntrospector;
|
|
12
11
|
}
|
|
13
12
|
export default SQLiteDialect;
|
package/dist/dialects/sqlite.mjs
CHANGED
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export class SQLiteDialect {
|
|
5
|
-
#config;
|
|
6
|
-
constructor(config = {}) {
|
|
7
|
-
this.#config = config;
|
|
8
|
-
}
|
|
9
|
-
createDriver() {
|
|
10
|
-
return new BunSQLDriver({
|
|
11
|
-
adapter: "sqlite",
|
|
12
|
-
...this.#config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
createQueryCompiler() {
|
|
16
|
-
return new SqliteQueryCompiler;
|
|
17
|
-
}
|
|
18
|
-
createAdapter() {
|
|
19
|
-
return new SqliteAdapter;
|
|
20
|
-
}
|
|
21
|
-
createIntrospector(db) {
|
|
22
|
-
return new SqliteIntrospector(db);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export default SQLiteDialect;
|
|
1
|
+
// @bun
|
|
2
|
+
import{a as t}from"./_chunks/mysql-x4fwf4rk.mjs";import{SqliteAdapter as i,SqliteIntrospector as o,SqliteQueryCompiler as a}from"kysely";class r{#e;constructor(e={}){this.#e=e}createDriver(){return new t({adapter:"sqlite",...this.#e})}createQueryCompiler(){return new a}createAdapter(){return new i}createIntrospector(e){return new o(e)}}var c=r;export{c as default,r as SQLiteDialect};
|