drizzle-orm 1.0.0-beta.1-f92627f → 1.0.0-beta.1-cdf226f

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.
Files changed (45) hide show
  1. package/effect/effect-wrapper.cjs +46 -0
  2. package/effect/effect-wrapper.cjs.map +1 -0
  3. package/effect/effect-wrapper.d.cts +8 -0
  4. package/effect/effect-wrapper.d.ts +8 -0
  5. package/effect/effect-wrapper.js +22 -0
  6. package/effect/effect-wrapper.js.map +1 -0
  7. package/effect/sqlite/db.cjs +371 -0
  8. package/effect/sqlite/db.cjs.map +1 -0
  9. package/effect/sqlite/db.d.cts +277 -0
  10. package/effect/sqlite/db.d.ts +277 -0
  11. package/effect/sqlite/db.js +351 -0
  12. package/effect/sqlite/db.js.map +1 -0
  13. package/effect/sqlite/driver.cjs +67 -0
  14. package/effect/sqlite/driver.cjs.map +1 -0
  15. package/effect/sqlite/driver.d.cts +4 -0
  16. package/effect/sqlite/driver.d.ts +4 -0
  17. package/effect/sqlite/driver.js +33 -0
  18. package/effect/sqlite/driver.js.map +1 -0
  19. package/effect/sqlite/index.cjs +25 -0
  20. package/effect/sqlite/index.cjs.map +1 -0
  21. package/effect/sqlite/index.d.cts +2 -0
  22. package/effect/sqlite/index.d.ts +2 -0
  23. package/effect/sqlite/index.js +3 -0
  24. package/effect/sqlite/index.js.map +1 -0
  25. package/effect/sqlite/query-builders/select.cjs +122 -0
  26. package/effect/sqlite/query-builders/select.cjs.map +1 -0
  27. package/effect/sqlite/query-builders/select.d.cts +62 -0
  28. package/effect/sqlite/query-builders/select.d.ts +62 -0
  29. package/effect/sqlite/query-builders/select.js +97 -0
  30. package/effect/sqlite/query-builders/select.js.map +1 -0
  31. package/effect/sqlite/session.cjs +237 -0
  32. package/effect/sqlite/session.cjs.map +1 -0
  33. package/effect/sqlite/session.d.cts +79 -0
  34. package/effect/sqlite/session.d.ts +79 -0
  35. package/effect/sqlite/session.js +212 -0
  36. package/effect/sqlite/session.js.map +1 -0
  37. package/package.json +139 -52
  38. package/sqlite-core/session.cjs.map +1 -1
  39. package/sqlite-core/session.d.cts +1 -1
  40. package/sqlite-core/session.d.ts +1 -1
  41. package/sqlite-core/session.js.map +1 -1
  42. package/version.cjs +1 -1
  43. package/version.d.cts +1 -1
  44. package/version.d.ts +1 -1
  45. package/version.js +1 -1
@@ -0,0 +1,277 @@
1
+ import type { SqliteClient } from '@effect/sql-sqlite-node/SqliteClient';
2
+ import type { SqlError } from '@effect/sql/SqlError';
3
+ import type { Effect } from 'effect/Effect';
4
+ import type * as V1 from "../../_relations.cjs";
5
+ import type { Cache } from "../../cache/core/cache.cjs";
6
+ import { entityKind } from "../../entity.cjs";
7
+ import type { AnyRelations, EmptyRelations } from "../../relations.cjs";
8
+ import { type SQL, type SQLWrapper } from "../../sql/sql.cjs";
9
+ import type { SQLiteAsyncDialect, SQLiteSyncDialect } from "../../sqlite-core/dialect.cjs";
10
+ import { _RelationalQueryBuilder } from "../../sqlite-core/query-builders/_query.cjs";
11
+ import { SQLiteCountBuilder } from "../../sqlite-core/query-builders/count.cjs";
12
+ import { SQLiteDeleteBase, SQLiteInsertBuilder, SQLiteUpdateBuilder } from "../../sqlite-core/query-builders/index.cjs";
13
+ import { RelationalQueryBuilder } from "../../sqlite-core/query-builders/query.cjs";
14
+ import type { SelectedFields } from "../../sqlite-core/query-builders/select.types.cjs";
15
+ import type { Result, SQLiteTransaction, SQLiteTransactionConfig } from "../../sqlite-core/session.cjs";
16
+ import type { WithBuilder } from "../../sqlite-core/subquery.cjs";
17
+ import type { SQLiteTable } from "../../sqlite-core/table.cjs";
18
+ import type { SQLiteViewBase } from "../../sqlite-core/view-base.cjs";
19
+ import { WithSubquery } from "../../subquery.cjs";
20
+ import type { DrizzleTypeError } from "../../utils.cjs";
21
+ import { EffectSQLiteSelectBuilder } from "./query-builders/select.cjs";
22
+ import type { EffectSQLiteSession } from "./session.cjs";
23
+ export declare class EffectSQLiteDatabase<TFullSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations, TSchema extends V1.TablesRelationalConfig = V1.ExtractTablesWithRelations<TFullSchema>> {
24
+ readonly rowModeRQB?: boolean | undefined;
25
+ readonly forbidJsonb?: boolean | undefined;
26
+ static readonly [entityKind]: string;
27
+ readonly _: {
28
+ readonly schema: TSchema | undefined;
29
+ readonly fullSchema: TFullSchema;
30
+ readonly tableNamesMap: Record<string, string>;
31
+ readonly relations: TRelations;
32
+ };
33
+ /** @deprecated */
34
+ _query: TFullSchema extends Record<string, never> ? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'> : {
35
+ [K in keyof TSchema]: _RelationalQueryBuilder<'sync', TFullSchema, TSchema, TSchema[K]>;
36
+ };
37
+ query: {
38
+ [K in keyof TRelations]: RelationalQueryBuilder<'sync', TRelations, TRelations[K]>;
39
+ };
40
+ constructor(
41
+ /** @internal */
42
+ dialect: {
43
+ sync: SQLiteSyncDialect;
44
+ async: SQLiteAsyncDialect;
45
+ }['sync'],
46
+ /** @internal */
47
+ session: EffectSQLiteSession<TFullSchema, TRelations, TSchema>, relations: TRelations, _schema: V1.RelationalSchemaConfig<TSchema> | undefined, rowModeRQB?: boolean | undefined, forbidJsonb?: boolean | undefined);
48
+ /**
49
+ * Creates a subquery that defines a temporary named result set as a CTE.
50
+ *
51
+ * It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
52
+ *
53
+ * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
54
+ *
55
+ * @param alias The alias for the subquery.
56
+ *
57
+ * Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
58
+ *
59
+ * @example
60
+ *
61
+ * ```ts
62
+ * // Create a subquery with alias 'sq' and use it in the select query
63
+ * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
64
+ *
65
+ * const result = yield* db.with(sq).select().from(sq);
66
+ * ```
67
+ *
68
+ * To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
69
+ *
70
+ * ```ts
71
+ * // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
72
+ * const sq = db.$with('sq').as(db.select({
73
+ * name: sql<string>`upper(${users.name})`.as('name'),
74
+ * })
75
+ * .from(users));
76
+ *
77
+ * const result = yield* db.with(sq).select({ name: sq.name }).from(sq);
78
+ * ```
79
+ */
80
+ $with: WithBuilder;
81
+ $count(source: SQLiteTable | SQLiteViewBase | SQL | SQLWrapper, filters?: SQL<unknown>): SQLiteCountBuilder<EffectSQLiteSession<TFullSchema, TRelations, TSchema>>;
82
+ /**
83
+ * Incorporates a previously defined CTE (using `$with`) into the main query.
84
+ *
85
+ * This method allows the main query to reference a temporary named result set.
86
+ *
87
+ * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
88
+ *
89
+ * @param queries The CTEs to incorporate into the main query.
90
+ *
91
+ * @example
92
+ *
93
+ * ```ts
94
+ * // Define a subquery 'sq' as a CTE using $with
95
+ * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
96
+ *
97
+ * // Incorporate the CTE 'sq' into the main query and select from it
98
+ * const result = yield* db.with(sq).select().from(sq);
99
+ * ```
100
+ */
101
+ with(...queries: WithSubquery[]): {
102
+ select: {
103
+ (): EffectSQLiteSelectBuilder<undefined>;
104
+ <TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
105
+ };
106
+ selectDistinct: {
107
+ (): EffectSQLiteSelectBuilder<undefined>;
108
+ <TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
109
+ };
110
+ update: <TTable extends SQLiteTable>(table: TTable) => SQLiteUpdateBuilder<TTable, "sync", unknown>;
111
+ insert: <TTable extends SQLiteTable>(into: TTable) => SQLiteInsertBuilder<TTable, "sync", unknown>;
112
+ delete: <TTable extends SQLiteTable>(from: TTable) => SQLiteDeleteBase<TTable, "sync", unknown>;
113
+ };
114
+ /**
115
+ * Creates a select query.
116
+ *
117
+ * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.
118
+ *
119
+ * Use `.from()` method to specify which table to select from.
120
+ *
121
+ * See docs: {@link https://orm.drizzle.team/docs/select}
122
+ *
123
+ * @param fields The selection object.
124
+ *
125
+ * @example
126
+ *
127
+ * ```ts
128
+ * // Select all columns and all rows from the 'cars' table
129
+ * const allCars: Car[] = yield* db.select().from(cars);
130
+ *
131
+ * // Select specific columns and all rows from the 'cars' table
132
+ * const carsIdsAndBrands: { id: number; brand: string }[] = yield* db.select({
133
+ * id: cars.id,
134
+ * brand: cars.brand
135
+ * })
136
+ * .from(cars);
137
+ * ```
138
+ *
139
+ * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
140
+ *
141
+ * ```ts
142
+ * // Select specific columns along with expression and all rows from the 'cars' table
143
+ * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = yield* db.select({
144
+ * id: cars.id,
145
+ * lowerBrand: sql<string>`lower(${cars.brand})`,
146
+ * })
147
+ * .from(cars);
148
+ * ```
149
+ */
150
+ select(): EffectSQLiteSelectBuilder<undefined>;
151
+ select<TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
152
+ /**
153
+ * Adds `distinct` expression to the select query.
154
+ *
155
+ * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.
156
+ *
157
+ * Use `.from()` method to specify which table to select from.
158
+ *
159
+ * See docs: {@link https://orm.drizzle.team/docs/select#distinct}
160
+ *
161
+ * @param fields The selection object.
162
+ *
163
+ * @example
164
+ *
165
+ * ```ts
166
+ * // Select all unique rows from the 'cars' table
167
+ * yield* db.selectDistinct()
168
+ * .from(cars)
169
+ * .orderBy(cars.id, cars.brand, cars.color);
170
+ *
171
+ * // Select all unique brands from the 'cars' table
172
+ * yield* db.selectDistinct({ brand: cars.brand })
173
+ * .from(cars)
174
+ * .orderBy(cars.brand);
175
+ * ```
176
+ */
177
+ selectDistinct(): EffectSQLiteSelectBuilder<undefined>;
178
+ selectDistinct<TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
179
+ /**
180
+ * Creates an update query.
181
+ *
182
+ * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
183
+ *
184
+ * Use `.set()` method to specify which values to update.
185
+ *
186
+ * See docs: {@link https://orm.drizzle.team/docs/update}
187
+ *
188
+ * @param table The table to update.
189
+ *
190
+ * @example
191
+ *
192
+ * ```ts
193
+ * // Update all rows in the 'cars' table
194
+ * yield* db.update(cars).set({ color: 'red' });
195
+ *
196
+ * // Update rows with filters and conditions
197
+ * yield* db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
198
+ *
199
+ * // Update with returning clause
200
+ * const updatedCar: Car[] = yield* db.update(cars)
201
+ * .set({ color: 'red' })
202
+ * .where(eq(cars.id, 1))
203
+ * .returning();
204
+ * ```
205
+ */
206
+ update<TTable extends SQLiteTable>(table: TTable): SQLiteUpdateBuilder<TTable, 'sync', unknown>;
207
+ $cache: {
208
+ invalidate: Cache['onMutate'];
209
+ };
210
+ /**
211
+ * Creates an insert query.
212
+ *
213
+ * Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
214
+ *
215
+ * See docs: {@link https://orm.drizzle.team/docs/insert}
216
+ *
217
+ * @param table The table to insert into.
218
+ *
219
+ * @example
220
+ *
221
+ * ```ts
222
+ * // Insert one row
223
+ * yield* db.insert(cars).values({ brand: 'BMW' });
224
+ *
225
+ * // Insert multiple rows
226
+ * yield* db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
227
+ *
228
+ * // Insert with returning clause
229
+ * const insertedCar: Car[] = yield* db.insert(cars)
230
+ * .values({ brand: 'BMW' })
231
+ * .returning();
232
+ * ```
233
+ */
234
+ insert<TTable extends SQLiteTable>(into: TTable): SQLiteInsertBuilder<TTable, 'sync', unknown>;
235
+ /**
236
+ * Creates a delete query.
237
+ *
238
+ * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
239
+ *
240
+ * See docs: {@link https://orm.drizzle.team/docs/delete}
241
+ *
242
+ * @param table The table to delete from.
243
+ *
244
+ * @example
245
+ *
246
+ * ```ts
247
+ * // Delete all rows in the 'cars' table
248
+ * yield* db.delete(cars);
249
+ *
250
+ * // Delete rows with filters and conditions
251
+ * yield* db.delete(cars).where(eq(cars.color, 'green'));
252
+ *
253
+ * // Delete with returning clause
254
+ * const deletedCar: Car[] = yield* db.delete(cars)
255
+ * .where(eq(cars.id, 1))
256
+ * .returning();
257
+ * ```
258
+ */
259
+ delete<TTable extends SQLiteTable>(from: TTable): SQLiteDeleteBase<TTable, 'sync', unknown>;
260
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
261
+ run: any;
262
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
263
+ all: any;
264
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
265
+ get: any;
266
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
267
+ values: any;
268
+ effectRun(query: SQLWrapper | string): Effect<unknown, SqlError, SqliteClient>;
269
+ effectAll<T = unknown>(query: SQLWrapper | string): Effect<T[], SqlError, SqliteClient>;
270
+ effectGet<T = unknown>(query: SQLWrapper | string): Effect<T, SqlError, SqliteClient>;
271
+ effectValues<T extends unknown[] = unknown[]>(query: SQLWrapper | string): Effect<T[], SqlError, SqliteClient>;
272
+ transaction<T>(transaction: (tx: SQLiteTransaction<'sync', unknown, TFullSchema, TRelations, TSchema>) => Result<'sync', T>, config?: SQLiteTransactionConfig): Result<'sync', T>;
273
+ }
274
+ export type SQLiteWithReplicas<Q> = Q & {
275
+ $primary: Q;
276
+ };
277
+ export declare const withReplicas: <TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TSchema extends V1.TablesRelationalConfig, Q extends EffectSQLiteDatabase<TFullSchema, TRelations, TSchema extends Record<string, unknown> ? V1.ExtractTablesWithRelations<TFullSchema> : TSchema>>(primary: Q, replicas: [Q, ...Q[]], getReplica?: (replicas: Q[]) => Q) => SQLiteWithReplicas<Q>;
@@ -0,0 +1,277 @@
1
+ import type { SqliteClient } from '@effect/sql-sqlite-node/SqliteClient';
2
+ import type { SqlError } from '@effect/sql/SqlError';
3
+ import type { Effect } from 'effect/Effect';
4
+ import type * as V1 from "../../_relations.js";
5
+ import type { Cache } from "../../cache/core/cache.js";
6
+ import { entityKind } from "../../entity.js";
7
+ import type { AnyRelations, EmptyRelations } from "../../relations.js";
8
+ import { type SQL, type SQLWrapper } from "../../sql/sql.js";
9
+ import type { SQLiteAsyncDialect, SQLiteSyncDialect } from "../../sqlite-core/dialect.js";
10
+ import { _RelationalQueryBuilder } from "../../sqlite-core/query-builders/_query.js";
11
+ import { SQLiteCountBuilder } from "../../sqlite-core/query-builders/count.js";
12
+ import { SQLiteDeleteBase, SQLiteInsertBuilder, SQLiteUpdateBuilder } from "../../sqlite-core/query-builders/index.js";
13
+ import { RelationalQueryBuilder } from "../../sqlite-core/query-builders/query.js";
14
+ import type { SelectedFields } from "../../sqlite-core/query-builders/select.types.js";
15
+ import type { Result, SQLiteTransaction, SQLiteTransactionConfig } from "../../sqlite-core/session.js";
16
+ import type { WithBuilder } from "../../sqlite-core/subquery.js";
17
+ import type { SQLiteTable } from "../../sqlite-core/table.js";
18
+ import type { SQLiteViewBase } from "../../sqlite-core/view-base.js";
19
+ import { WithSubquery } from "../../subquery.js";
20
+ import type { DrizzleTypeError } from "../../utils.js";
21
+ import { EffectSQLiteSelectBuilder } from "./query-builders/select.js";
22
+ import type { EffectSQLiteSession } from "./session.js";
23
+ export declare class EffectSQLiteDatabase<TFullSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations, TSchema extends V1.TablesRelationalConfig = V1.ExtractTablesWithRelations<TFullSchema>> {
24
+ readonly rowModeRQB?: boolean | undefined;
25
+ readonly forbidJsonb?: boolean | undefined;
26
+ static readonly [entityKind]: string;
27
+ readonly _: {
28
+ readonly schema: TSchema | undefined;
29
+ readonly fullSchema: TFullSchema;
30
+ readonly tableNamesMap: Record<string, string>;
31
+ readonly relations: TRelations;
32
+ };
33
+ /** @deprecated */
34
+ _query: TFullSchema extends Record<string, never> ? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'> : {
35
+ [K in keyof TSchema]: _RelationalQueryBuilder<'sync', TFullSchema, TSchema, TSchema[K]>;
36
+ };
37
+ query: {
38
+ [K in keyof TRelations]: RelationalQueryBuilder<'sync', TRelations, TRelations[K]>;
39
+ };
40
+ constructor(
41
+ /** @internal */
42
+ dialect: {
43
+ sync: SQLiteSyncDialect;
44
+ async: SQLiteAsyncDialect;
45
+ }['sync'],
46
+ /** @internal */
47
+ session: EffectSQLiteSession<TFullSchema, TRelations, TSchema>, relations: TRelations, _schema: V1.RelationalSchemaConfig<TSchema> | undefined, rowModeRQB?: boolean | undefined, forbidJsonb?: boolean | undefined);
48
+ /**
49
+ * Creates a subquery that defines a temporary named result set as a CTE.
50
+ *
51
+ * It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
52
+ *
53
+ * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
54
+ *
55
+ * @param alias The alias for the subquery.
56
+ *
57
+ * Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
58
+ *
59
+ * @example
60
+ *
61
+ * ```ts
62
+ * // Create a subquery with alias 'sq' and use it in the select query
63
+ * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
64
+ *
65
+ * const result = yield* db.with(sq).select().from(sq);
66
+ * ```
67
+ *
68
+ * To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
69
+ *
70
+ * ```ts
71
+ * // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
72
+ * const sq = db.$with('sq').as(db.select({
73
+ * name: sql<string>`upper(${users.name})`.as('name'),
74
+ * })
75
+ * .from(users));
76
+ *
77
+ * const result = yield* db.with(sq).select({ name: sq.name }).from(sq);
78
+ * ```
79
+ */
80
+ $with: WithBuilder;
81
+ $count(source: SQLiteTable | SQLiteViewBase | SQL | SQLWrapper, filters?: SQL<unknown>): SQLiteCountBuilder<EffectSQLiteSession<TFullSchema, TRelations, TSchema>>;
82
+ /**
83
+ * Incorporates a previously defined CTE (using `$with`) into the main query.
84
+ *
85
+ * This method allows the main query to reference a temporary named result set.
86
+ *
87
+ * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
88
+ *
89
+ * @param queries The CTEs to incorporate into the main query.
90
+ *
91
+ * @example
92
+ *
93
+ * ```ts
94
+ * // Define a subquery 'sq' as a CTE using $with
95
+ * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
96
+ *
97
+ * // Incorporate the CTE 'sq' into the main query and select from it
98
+ * const result = yield* db.with(sq).select().from(sq);
99
+ * ```
100
+ */
101
+ with(...queries: WithSubquery[]): {
102
+ select: {
103
+ (): EffectSQLiteSelectBuilder<undefined>;
104
+ <TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
105
+ };
106
+ selectDistinct: {
107
+ (): EffectSQLiteSelectBuilder<undefined>;
108
+ <TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
109
+ };
110
+ update: <TTable extends SQLiteTable>(table: TTable) => SQLiteUpdateBuilder<TTable, "sync", unknown>;
111
+ insert: <TTable extends SQLiteTable>(into: TTable) => SQLiteInsertBuilder<TTable, "sync", unknown>;
112
+ delete: <TTable extends SQLiteTable>(from: TTable) => SQLiteDeleteBase<TTable, "sync", unknown>;
113
+ };
114
+ /**
115
+ * Creates a select query.
116
+ *
117
+ * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.
118
+ *
119
+ * Use `.from()` method to specify which table to select from.
120
+ *
121
+ * See docs: {@link https://orm.drizzle.team/docs/select}
122
+ *
123
+ * @param fields The selection object.
124
+ *
125
+ * @example
126
+ *
127
+ * ```ts
128
+ * // Select all columns and all rows from the 'cars' table
129
+ * const allCars: Car[] = yield* db.select().from(cars);
130
+ *
131
+ * // Select specific columns and all rows from the 'cars' table
132
+ * const carsIdsAndBrands: { id: number; brand: string }[] = yield* db.select({
133
+ * id: cars.id,
134
+ * brand: cars.brand
135
+ * })
136
+ * .from(cars);
137
+ * ```
138
+ *
139
+ * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
140
+ *
141
+ * ```ts
142
+ * // Select specific columns along with expression and all rows from the 'cars' table
143
+ * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = yield* db.select({
144
+ * id: cars.id,
145
+ * lowerBrand: sql<string>`lower(${cars.brand})`,
146
+ * })
147
+ * .from(cars);
148
+ * ```
149
+ */
150
+ select(): EffectSQLiteSelectBuilder<undefined>;
151
+ select<TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
152
+ /**
153
+ * Adds `distinct` expression to the select query.
154
+ *
155
+ * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.
156
+ *
157
+ * Use `.from()` method to specify which table to select from.
158
+ *
159
+ * See docs: {@link https://orm.drizzle.team/docs/select#distinct}
160
+ *
161
+ * @param fields The selection object.
162
+ *
163
+ * @example
164
+ *
165
+ * ```ts
166
+ * // Select all unique rows from the 'cars' table
167
+ * yield* db.selectDistinct()
168
+ * .from(cars)
169
+ * .orderBy(cars.id, cars.brand, cars.color);
170
+ *
171
+ * // Select all unique brands from the 'cars' table
172
+ * yield* db.selectDistinct({ brand: cars.brand })
173
+ * .from(cars)
174
+ * .orderBy(cars.brand);
175
+ * ```
176
+ */
177
+ selectDistinct(): EffectSQLiteSelectBuilder<undefined>;
178
+ selectDistinct<TSelection extends SelectedFields>(fields: TSelection): EffectSQLiteSelectBuilder<TSelection>;
179
+ /**
180
+ * Creates an update query.
181
+ *
182
+ * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
183
+ *
184
+ * Use `.set()` method to specify which values to update.
185
+ *
186
+ * See docs: {@link https://orm.drizzle.team/docs/update}
187
+ *
188
+ * @param table The table to update.
189
+ *
190
+ * @example
191
+ *
192
+ * ```ts
193
+ * // Update all rows in the 'cars' table
194
+ * yield* db.update(cars).set({ color: 'red' });
195
+ *
196
+ * // Update rows with filters and conditions
197
+ * yield* db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
198
+ *
199
+ * // Update with returning clause
200
+ * const updatedCar: Car[] = yield* db.update(cars)
201
+ * .set({ color: 'red' })
202
+ * .where(eq(cars.id, 1))
203
+ * .returning();
204
+ * ```
205
+ */
206
+ update<TTable extends SQLiteTable>(table: TTable): SQLiteUpdateBuilder<TTable, 'sync', unknown>;
207
+ $cache: {
208
+ invalidate: Cache['onMutate'];
209
+ };
210
+ /**
211
+ * Creates an insert query.
212
+ *
213
+ * Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
214
+ *
215
+ * See docs: {@link https://orm.drizzle.team/docs/insert}
216
+ *
217
+ * @param table The table to insert into.
218
+ *
219
+ * @example
220
+ *
221
+ * ```ts
222
+ * // Insert one row
223
+ * yield* db.insert(cars).values({ brand: 'BMW' });
224
+ *
225
+ * // Insert multiple rows
226
+ * yield* db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
227
+ *
228
+ * // Insert with returning clause
229
+ * const insertedCar: Car[] = yield* db.insert(cars)
230
+ * .values({ brand: 'BMW' })
231
+ * .returning();
232
+ * ```
233
+ */
234
+ insert<TTable extends SQLiteTable>(into: TTable): SQLiteInsertBuilder<TTable, 'sync', unknown>;
235
+ /**
236
+ * Creates a delete query.
237
+ *
238
+ * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
239
+ *
240
+ * See docs: {@link https://orm.drizzle.team/docs/delete}
241
+ *
242
+ * @param table The table to delete from.
243
+ *
244
+ * @example
245
+ *
246
+ * ```ts
247
+ * // Delete all rows in the 'cars' table
248
+ * yield* db.delete(cars);
249
+ *
250
+ * // Delete rows with filters and conditions
251
+ * yield* db.delete(cars).where(eq(cars.color, 'green'));
252
+ *
253
+ * // Delete with returning clause
254
+ * const deletedCar: Car[] = yield* db.delete(cars)
255
+ * .where(eq(cars.id, 1))
256
+ * .returning();
257
+ * ```
258
+ */
259
+ delete<TTable extends SQLiteTable>(from: TTable): SQLiteDeleteBase<TTable, 'sync', unknown>;
260
+ /** @deprecated Use `.effectRun()` for `Effect` compatibility */
261
+ run: any;
262
+ /** @deprecated Use `.effectAll()` for `Effect` compatibility */
263
+ all: any;
264
+ /** @deprecated Use `.effectGet()` for `Effect` compatibility */
265
+ get: any;
266
+ /** @deprecated Use `.effectValues()` for `Effect` compatibility */
267
+ values: any;
268
+ effectRun(query: SQLWrapper | string): Effect<unknown, SqlError, SqliteClient>;
269
+ effectAll<T = unknown>(query: SQLWrapper | string): Effect<T[], SqlError, SqliteClient>;
270
+ effectGet<T = unknown>(query: SQLWrapper | string): Effect<T, SqlError, SqliteClient>;
271
+ effectValues<T extends unknown[] = unknown[]>(query: SQLWrapper | string): Effect<T[], SqlError, SqliteClient>;
272
+ transaction<T>(transaction: (tx: SQLiteTransaction<'sync', unknown, TFullSchema, TRelations, TSchema>) => Result<'sync', T>, config?: SQLiteTransactionConfig): Result<'sync', T>;
273
+ }
274
+ export type SQLiteWithReplicas<Q> = Q & {
275
+ $primary: Q;
276
+ };
277
+ export declare const withReplicas: <TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TSchema extends V1.TablesRelationalConfig, Q extends EffectSQLiteDatabase<TFullSchema, TRelations, TSchema extends Record<string, unknown> ? V1.ExtractTablesWithRelations<TFullSchema> : TSchema>>(primary: Q, replicas: [Q, ...Q[]], getReplica?: (replicas: Q[]) => Q) => SQLiteWithReplicas<Q>;