@type32/tauri-sqlite-orm 0.1.4 → 0.1.6
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 +14 -6
- package/dist/index.d.mts +152 -8
- package/dist/index.d.ts +152 -8
- package/dist/index.js +547 -31
- package/dist/index.mjs +525 -30
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,6 +56,20 @@ const res = await db.query.users.findMany({
|
|
|
56
56
|
});
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### Documentation
|
|
60
|
+
|
|
61
|
+
- See full docs in `docs/`:
|
|
62
|
+
- Getting Started: `docs/getting-started.md`
|
|
63
|
+
- Schema & Types: `docs/schema-and-types.md`
|
|
64
|
+
- Relations: `docs/relations.md`
|
|
65
|
+
- Queries (select): `docs/queries-select.md`
|
|
66
|
+
- CRUD (insert): `docs/crud-insert.md`
|
|
67
|
+
- CRUD (update): `docs/crud-update.md`
|
|
68
|
+
- CRUD (delete): `docs/crud-delete.md`
|
|
69
|
+
- SQL Helpers: `docs/sql-helpers.md`
|
|
70
|
+
- Indexes & Constraints: `docs/indexes-constraints.md`
|
|
71
|
+
- Migrations: `docs/migrations.md`
|
|
72
|
+
|
|
59
73
|
### Schema builder
|
|
60
74
|
|
|
61
75
|
Chainable, Drizzle-style:
|
|
@@ -236,12 +250,6 @@ export default defineNuxtPlugin(async () => {
|
|
|
236
250
|
});
|
|
237
251
|
```
|
|
238
252
|
|
|
239
|
-
### Roadmap
|
|
240
|
-
|
|
241
|
-
- Aliasing helpers and typed orderBy (asc(users.id)) for findMany
|
|
242
|
-
- Unique(), check(), composite primary/unique constraints
|
|
243
|
-
- Insert returning / batch returning (where feasible)
|
|
244
|
-
|
|
245
253
|
### License
|
|
246
254
|
|
|
247
255
|
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -79,11 +79,62 @@ declare function timestamp(name: string): ColumnBuilder<Date>;
|
|
|
79
79
|
declare function timestamp(): ColumnBuilder<Date>;
|
|
80
80
|
declare function increments(name: string): ColumnBuilder<number>;
|
|
81
81
|
declare function increments(): ColumnBuilder<number>;
|
|
82
|
+
type UniqueSpec = {
|
|
83
|
+
name?: string;
|
|
84
|
+
columns: string[];
|
|
85
|
+
};
|
|
86
|
+
type PrimaryKeySpec = {
|
|
87
|
+
name?: string;
|
|
88
|
+
columns: string[];
|
|
89
|
+
};
|
|
90
|
+
type CheckSpec = {
|
|
91
|
+
name: string;
|
|
92
|
+
expr: SQLExpression | {
|
|
93
|
+
raw: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
type ForeignKeySpec = {
|
|
97
|
+
name?: string;
|
|
98
|
+
columns: string[];
|
|
99
|
+
foreignTable: string;
|
|
100
|
+
foreignColumns: string[];
|
|
101
|
+
onDelete?: UpdateDeleteAction;
|
|
102
|
+
onUpdate?: UpdateDeleteAction;
|
|
103
|
+
};
|
|
104
|
+
type IndexSpec = {
|
|
105
|
+
name: string;
|
|
106
|
+
columns: string[];
|
|
107
|
+
unique?: boolean;
|
|
108
|
+
where?: SQLExpression;
|
|
109
|
+
};
|
|
110
|
+
declare function unique(name?: string): {
|
|
111
|
+
on: (...cols: Column<any>[]) => UniqueSpec;
|
|
112
|
+
};
|
|
113
|
+
declare function primaryKey(opts: {
|
|
114
|
+
name?: string;
|
|
115
|
+
columns: Column<any>[];
|
|
116
|
+
}): PrimaryKeySpec;
|
|
117
|
+
declare function check(name: string, expr: SQLExpression): CheckSpec;
|
|
118
|
+
declare function foreignKey(opts: {
|
|
119
|
+
name?: string;
|
|
120
|
+
columns: Column<any>[];
|
|
121
|
+
foreignColumns: Column<any>[];
|
|
122
|
+
onDelete?: UpdateDeleteAction;
|
|
123
|
+
onUpdate?: UpdateDeleteAction;
|
|
124
|
+
}): ForeignKeySpec;
|
|
125
|
+
declare function index(name: string): {
|
|
126
|
+
on: (...cols: Column<any>[]) => IndexSpec;
|
|
127
|
+
where: (expr: SQLExpression) => IndexSpec;
|
|
128
|
+
};
|
|
129
|
+
declare function uniqueIndex(name: string): {
|
|
130
|
+
on: (...cols: Column<any>[]) => IndexSpec;
|
|
131
|
+
where: (expr: SQLExpression) => IndexSpec;
|
|
132
|
+
};
|
|
82
133
|
type SchemaDefinition = Record<string, Column<any>>;
|
|
83
134
|
type InferModel<T extends SchemaDefinition> = {
|
|
84
135
|
[K in keyof T]: T[K]["_dataType"];
|
|
85
136
|
};
|
|
86
|
-
declare function defineTable<T extends SchemaDefinition>(tableName: string, schema: T): any & InferModel<T>;
|
|
137
|
+
declare function defineTable<T extends SchemaDefinition>(tableName: string, schema: T, extras?: (t: any) => Array<UniqueSpec | PrimaryKeySpec | CheckSpec | ForeignKeySpec | IndexSpec>): any & InferModel<T>;
|
|
87
138
|
type Table<T extends SchemaDefinition> = ReturnType<typeof defineTable<T>>;
|
|
88
139
|
|
|
89
140
|
interface SQL {
|
|
@@ -92,6 +143,11 @@ interface SQL {
|
|
|
92
143
|
bindings: any[];
|
|
93
144
|
};
|
|
94
145
|
}
|
|
146
|
+
declare function raw(strings: TemplateStringsArray, ...values: any[]): SQL;
|
|
147
|
+
declare function getQualifiedName(column: Column): string;
|
|
148
|
+
declare const and: (...conditions: SQL[]) => SQL;
|
|
149
|
+
declare const or: (...conditions: SQL[]) => SQL;
|
|
150
|
+
declare const not: (condition: SQL) => SQL;
|
|
95
151
|
declare const eq: (column: Column, value: any) => SQL;
|
|
96
152
|
declare const ne: (column: Column, value: any) => SQL;
|
|
97
153
|
declare const gt: (column: Column, value: number | Date) => SQL;
|
|
@@ -99,6 +155,36 @@ declare const gte: (column: Column, value: number | Date) => SQL;
|
|
|
99
155
|
declare const lt: (column: Column, value: number | Date) => SQL;
|
|
100
156
|
declare const lte: (column: Column, value: number | Date) => SQL;
|
|
101
157
|
declare const like: (column: Column<string>, value: string) => SQL;
|
|
158
|
+
declare const ilike: (column: Column<string>, value: string | Column) => SQL;
|
|
159
|
+
declare const notIlike: (column: Column<string>, value: string | Column) => SQL;
|
|
160
|
+
declare const isNull: (column: Column) => SQL;
|
|
161
|
+
declare const isNotNull: (column: Column) => SQL;
|
|
162
|
+
declare const between: (column: Column, from: number | string | Date | Column, to: number | string | Date | Column) => SQL;
|
|
163
|
+
declare const notBetween: (column: Column, from: number | string | Date | Column, to: number | string | Date | Column) => SQL;
|
|
164
|
+
declare const inArray: (column: Column, valuesOrQuery: any[] | SQL | {
|
|
165
|
+
toSQL: () => {
|
|
166
|
+
clause: string;
|
|
167
|
+
bindings: any[];
|
|
168
|
+
};
|
|
169
|
+
}) => SQL;
|
|
170
|
+
declare const notInArray: (column: Column, valuesOrQuery: any[] | SQL | {
|
|
171
|
+
toSQL: () => {
|
|
172
|
+
clause: string;
|
|
173
|
+
bindings: any[];
|
|
174
|
+
};
|
|
175
|
+
}) => SQL;
|
|
176
|
+
declare const exists: (subquery: SQL | {
|
|
177
|
+
toSQL: () => {
|
|
178
|
+
clause: string;
|
|
179
|
+
bindings: any[];
|
|
180
|
+
};
|
|
181
|
+
}) => SQL;
|
|
182
|
+
declare const notExists: (subquery: SQL | {
|
|
183
|
+
toSQL: () => {
|
|
184
|
+
clause: string;
|
|
185
|
+
bindings: any[];
|
|
186
|
+
};
|
|
187
|
+
}) => SQL;
|
|
102
188
|
declare const asc: (column: Column) => string;
|
|
103
189
|
declare const desc: (column: Column) => string;
|
|
104
190
|
|
|
@@ -110,16 +196,23 @@ declare class SelectQueryBuilder<T> {
|
|
|
110
196
|
private _orderBy;
|
|
111
197
|
private _limit;
|
|
112
198
|
private _offset;
|
|
113
|
-
private
|
|
199
|
+
private _groupBy;
|
|
200
|
+
private _having;
|
|
201
|
+
private _distinct;
|
|
114
202
|
private _dbProvider;
|
|
115
203
|
constructor(dbProvider: () => Promise<Database>, fields?: Record<string, Column<any>>);
|
|
204
|
+
distinct(): this;
|
|
205
|
+
select(fields: Record<string, Column<any> | SQL>): this;
|
|
116
206
|
from(table: Table<any>): this;
|
|
117
|
-
where(...conditions: SQL[]): this;
|
|
207
|
+
where(...conditions: (SQL | undefined)[]): this;
|
|
118
208
|
leftJoin(otherTable: Table<any>, on: SQL): this;
|
|
119
|
-
|
|
209
|
+
groupBy(...exprs: (Column | string)[]): this;
|
|
210
|
+
having(...conditions: SQL[]): this;
|
|
211
|
+
orderBy(...clauses: (string | Column<any> | SQL)[]): this;
|
|
120
212
|
limit(value: number): this;
|
|
121
213
|
offset(value: number): this;
|
|
122
214
|
execute(): Promise<T[]>;
|
|
215
|
+
iterator(): Promise<AsyncIterableIterator<T>>;
|
|
123
216
|
}
|
|
124
217
|
declare class TauriORM {
|
|
125
218
|
query: Record<string, any>;
|
|
@@ -130,25 +223,76 @@ declare class TauriORM {
|
|
|
130
223
|
private getDb;
|
|
131
224
|
configureQuery(tables: Record<string, Table<any>>, relations: Record<string, Record<string, RelationConfig>>): void;
|
|
132
225
|
select<T>(fields?: Record<string, Column<any>>): SelectQueryBuilder<T>;
|
|
226
|
+
selectDistinct<T>(fields?: Record<string, Column<any>>): SelectQueryBuilder<T>;
|
|
133
227
|
insert(table: Table<any>): {
|
|
134
228
|
_table: any;
|
|
135
229
|
_rows: Record<string, any>[];
|
|
230
|
+
_selectSql: {
|
|
231
|
+
clause: string;
|
|
232
|
+
bindings: any[];
|
|
233
|
+
} | null;
|
|
234
|
+
_conflict: null | {
|
|
235
|
+
kind: "doNothing";
|
|
236
|
+
target?: string | string[];
|
|
237
|
+
where?: SQL;
|
|
238
|
+
} | {
|
|
239
|
+
kind: "doUpdate";
|
|
240
|
+
target: string | string[];
|
|
241
|
+
targetWhere?: SQL;
|
|
242
|
+
set: Record<string, any>;
|
|
243
|
+
setWhere?: SQL;
|
|
244
|
+
};
|
|
245
|
+
_returning: null | "__RETURNING_ID__" | Record<string, Column<any>>;
|
|
136
246
|
values(rowOrRows: Record<string, any> | Record<string, any>[]): /*elided*/ any;
|
|
137
|
-
|
|
247
|
+
select(qb: {
|
|
248
|
+
toSQL?: () => {
|
|
249
|
+
clause: string;
|
|
250
|
+
bindings: any[];
|
|
251
|
+
};
|
|
252
|
+
} | SQL): /*elided*/ any;
|
|
253
|
+
returning(fields?: Record<string, Column<any>>): any;
|
|
254
|
+
$returningId(): any;
|
|
255
|
+
onConflictDoNothing(opts?: {
|
|
256
|
+
target?: Column<any> | Column<any>[];
|
|
257
|
+
where?: SQL;
|
|
258
|
+
}): /*elided*/ any;
|
|
259
|
+
onConflictDoUpdate(opts: {
|
|
260
|
+
target: Column<any> | Column<any>[];
|
|
261
|
+
targetWhere?: SQL;
|
|
262
|
+
set: Record<string, any>;
|
|
263
|
+
setWhere?: SQL;
|
|
264
|
+
}): /*elided*/ any;
|
|
265
|
+
execute(): Promise<any>;
|
|
266
|
+
_buildConflictClause(): string;
|
|
267
|
+
_executeWithReturning(db: any, query: string, bindings: any[]): Promise<any>;
|
|
138
268
|
};
|
|
139
269
|
update(table: Table<any>): {
|
|
140
270
|
_table: any;
|
|
141
271
|
_data: Record<string, any> | null;
|
|
142
272
|
_where: Record<string, any> | SQL | null;
|
|
273
|
+
_orderBy: Array<string | SQL>;
|
|
274
|
+
_limit: number | null;
|
|
275
|
+
_from: Table<any> | null;
|
|
276
|
+
_returning: null | Record<string, Column<any>>;
|
|
143
277
|
set(data: Record<string, any>): /*elided*/ any;
|
|
144
278
|
where(cond: Record<string, any> | SQL): /*elided*/ any;
|
|
145
|
-
|
|
279
|
+
orderBy(...clauses: (string | Column<any> | SQL)[]): /*elided*/ any;
|
|
280
|
+
limit(n: number): /*elided*/ any;
|
|
281
|
+
from(tbl: Table<any>): /*elided*/ any;
|
|
282
|
+
returning(fields?: Record<string, Column<any>>): any;
|
|
283
|
+
execute(): Promise<unknown>;
|
|
146
284
|
};
|
|
147
285
|
delete(table: Table<any>): {
|
|
148
286
|
_table: any;
|
|
149
287
|
_where: Record<string, any> | SQL | null;
|
|
288
|
+
_orderBy: Array<string | SQL>;
|
|
289
|
+
_limit: number | null;
|
|
290
|
+
_returning: null | Record<string, Column<any>>;
|
|
150
291
|
where(cond: Record<string, any> | SQL): /*elided*/ any;
|
|
151
|
-
|
|
292
|
+
orderBy(...clauses: (string | Column<any> | SQL)[]): /*elided*/ any;
|
|
293
|
+
limit(n: number): /*elided*/ any;
|
|
294
|
+
returning(fields?: Record<string, Column<any>>): any;
|
|
295
|
+
execute(): Promise<unknown>;
|
|
152
296
|
};
|
|
153
297
|
run(query: string, bindings?: any[]): Promise<void>;
|
|
154
298
|
private generateCreateTableSql;
|
|
@@ -262,4 +406,4 @@ declare function makeQueryAPI(tables: Record<string, Table<any>>, relDefs: Recor
|
|
|
262
406
|
}) => Promise<any | null>;
|
|
263
407
|
}; };
|
|
264
408
|
|
|
265
|
-
export { type BlobMode, type Column, type ColumnBuilder, type IntegerMode, type ManyRelation, type NumericMode, type OneRelation, type SQL, type SQLExpression, type Table, TauriORM, type UpdateDeleteAction, asc, blob, boolean, defineTable, desc, eq, gt, gte, increments, integer, like, lt, lte, makeQueryAPI, ne, numeric, real, relations, sql, text, timestamp };
|
|
409
|
+
export { type BlobMode, type CheckSpec, type Column, type ColumnBuilder, type ForeignKeySpec, type IndexSpec, type IntegerMode, type ManyRelation, type NumericMode, type OneRelation, type PrimaryKeySpec, type SQL, type SQLExpression, type Table, TauriORM, type UniqueSpec, type UpdateDeleteAction, and, asc, between, blob, boolean, check, defineTable, desc, eq, exists, foreignKey, getQualifiedName, gt, gte, ilike, inArray, increments, index, integer, isNotNull, isNull, like, lt, lte, makeQueryAPI, ne, not, notBetween, notExists, notIlike, notInArray, numeric, or, primaryKey, raw, real, relations, sql, text, timestamp, unique, uniqueIndex };
|
package/dist/index.d.ts
CHANGED
|
@@ -79,11 +79,62 @@ declare function timestamp(name: string): ColumnBuilder<Date>;
|
|
|
79
79
|
declare function timestamp(): ColumnBuilder<Date>;
|
|
80
80
|
declare function increments(name: string): ColumnBuilder<number>;
|
|
81
81
|
declare function increments(): ColumnBuilder<number>;
|
|
82
|
+
type UniqueSpec = {
|
|
83
|
+
name?: string;
|
|
84
|
+
columns: string[];
|
|
85
|
+
};
|
|
86
|
+
type PrimaryKeySpec = {
|
|
87
|
+
name?: string;
|
|
88
|
+
columns: string[];
|
|
89
|
+
};
|
|
90
|
+
type CheckSpec = {
|
|
91
|
+
name: string;
|
|
92
|
+
expr: SQLExpression | {
|
|
93
|
+
raw: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
type ForeignKeySpec = {
|
|
97
|
+
name?: string;
|
|
98
|
+
columns: string[];
|
|
99
|
+
foreignTable: string;
|
|
100
|
+
foreignColumns: string[];
|
|
101
|
+
onDelete?: UpdateDeleteAction;
|
|
102
|
+
onUpdate?: UpdateDeleteAction;
|
|
103
|
+
};
|
|
104
|
+
type IndexSpec = {
|
|
105
|
+
name: string;
|
|
106
|
+
columns: string[];
|
|
107
|
+
unique?: boolean;
|
|
108
|
+
where?: SQLExpression;
|
|
109
|
+
};
|
|
110
|
+
declare function unique(name?: string): {
|
|
111
|
+
on: (...cols: Column<any>[]) => UniqueSpec;
|
|
112
|
+
};
|
|
113
|
+
declare function primaryKey(opts: {
|
|
114
|
+
name?: string;
|
|
115
|
+
columns: Column<any>[];
|
|
116
|
+
}): PrimaryKeySpec;
|
|
117
|
+
declare function check(name: string, expr: SQLExpression): CheckSpec;
|
|
118
|
+
declare function foreignKey(opts: {
|
|
119
|
+
name?: string;
|
|
120
|
+
columns: Column<any>[];
|
|
121
|
+
foreignColumns: Column<any>[];
|
|
122
|
+
onDelete?: UpdateDeleteAction;
|
|
123
|
+
onUpdate?: UpdateDeleteAction;
|
|
124
|
+
}): ForeignKeySpec;
|
|
125
|
+
declare function index(name: string): {
|
|
126
|
+
on: (...cols: Column<any>[]) => IndexSpec;
|
|
127
|
+
where: (expr: SQLExpression) => IndexSpec;
|
|
128
|
+
};
|
|
129
|
+
declare function uniqueIndex(name: string): {
|
|
130
|
+
on: (...cols: Column<any>[]) => IndexSpec;
|
|
131
|
+
where: (expr: SQLExpression) => IndexSpec;
|
|
132
|
+
};
|
|
82
133
|
type SchemaDefinition = Record<string, Column<any>>;
|
|
83
134
|
type InferModel<T extends SchemaDefinition> = {
|
|
84
135
|
[K in keyof T]: T[K]["_dataType"];
|
|
85
136
|
};
|
|
86
|
-
declare function defineTable<T extends SchemaDefinition>(tableName: string, schema: T): any & InferModel<T>;
|
|
137
|
+
declare function defineTable<T extends SchemaDefinition>(tableName: string, schema: T, extras?: (t: any) => Array<UniqueSpec | PrimaryKeySpec | CheckSpec | ForeignKeySpec | IndexSpec>): any & InferModel<T>;
|
|
87
138
|
type Table<T extends SchemaDefinition> = ReturnType<typeof defineTable<T>>;
|
|
88
139
|
|
|
89
140
|
interface SQL {
|
|
@@ -92,6 +143,11 @@ interface SQL {
|
|
|
92
143
|
bindings: any[];
|
|
93
144
|
};
|
|
94
145
|
}
|
|
146
|
+
declare function raw(strings: TemplateStringsArray, ...values: any[]): SQL;
|
|
147
|
+
declare function getQualifiedName(column: Column): string;
|
|
148
|
+
declare const and: (...conditions: SQL[]) => SQL;
|
|
149
|
+
declare const or: (...conditions: SQL[]) => SQL;
|
|
150
|
+
declare const not: (condition: SQL) => SQL;
|
|
95
151
|
declare const eq: (column: Column, value: any) => SQL;
|
|
96
152
|
declare const ne: (column: Column, value: any) => SQL;
|
|
97
153
|
declare const gt: (column: Column, value: number | Date) => SQL;
|
|
@@ -99,6 +155,36 @@ declare const gte: (column: Column, value: number | Date) => SQL;
|
|
|
99
155
|
declare const lt: (column: Column, value: number | Date) => SQL;
|
|
100
156
|
declare const lte: (column: Column, value: number | Date) => SQL;
|
|
101
157
|
declare const like: (column: Column<string>, value: string) => SQL;
|
|
158
|
+
declare const ilike: (column: Column<string>, value: string | Column) => SQL;
|
|
159
|
+
declare const notIlike: (column: Column<string>, value: string | Column) => SQL;
|
|
160
|
+
declare const isNull: (column: Column) => SQL;
|
|
161
|
+
declare const isNotNull: (column: Column) => SQL;
|
|
162
|
+
declare const between: (column: Column, from: number | string | Date | Column, to: number | string | Date | Column) => SQL;
|
|
163
|
+
declare const notBetween: (column: Column, from: number | string | Date | Column, to: number | string | Date | Column) => SQL;
|
|
164
|
+
declare const inArray: (column: Column, valuesOrQuery: any[] | SQL | {
|
|
165
|
+
toSQL: () => {
|
|
166
|
+
clause: string;
|
|
167
|
+
bindings: any[];
|
|
168
|
+
};
|
|
169
|
+
}) => SQL;
|
|
170
|
+
declare const notInArray: (column: Column, valuesOrQuery: any[] | SQL | {
|
|
171
|
+
toSQL: () => {
|
|
172
|
+
clause: string;
|
|
173
|
+
bindings: any[];
|
|
174
|
+
};
|
|
175
|
+
}) => SQL;
|
|
176
|
+
declare const exists: (subquery: SQL | {
|
|
177
|
+
toSQL: () => {
|
|
178
|
+
clause: string;
|
|
179
|
+
bindings: any[];
|
|
180
|
+
};
|
|
181
|
+
}) => SQL;
|
|
182
|
+
declare const notExists: (subquery: SQL | {
|
|
183
|
+
toSQL: () => {
|
|
184
|
+
clause: string;
|
|
185
|
+
bindings: any[];
|
|
186
|
+
};
|
|
187
|
+
}) => SQL;
|
|
102
188
|
declare const asc: (column: Column) => string;
|
|
103
189
|
declare const desc: (column: Column) => string;
|
|
104
190
|
|
|
@@ -110,16 +196,23 @@ declare class SelectQueryBuilder<T> {
|
|
|
110
196
|
private _orderBy;
|
|
111
197
|
private _limit;
|
|
112
198
|
private _offset;
|
|
113
|
-
private
|
|
199
|
+
private _groupBy;
|
|
200
|
+
private _having;
|
|
201
|
+
private _distinct;
|
|
114
202
|
private _dbProvider;
|
|
115
203
|
constructor(dbProvider: () => Promise<Database>, fields?: Record<string, Column<any>>);
|
|
204
|
+
distinct(): this;
|
|
205
|
+
select(fields: Record<string, Column<any> | SQL>): this;
|
|
116
206
|
from(table: Table<any>): this;
|
|
117
|
-
where(...conditions: SQL[]): this;
|
|
207
|
+
where(...conditions: (SQL | undefined)[]): this;
|
|
118
208
|
leftJoin(otherTable: Table<any>, on: SQL): this;
|
|
119
|
-
|
|
209
|
+
groupBy(...exprs: (Column | string)[]): this;
|
|
210
|
+
having(...conditions: SQL[]): this;
|
|
211
|
+
orderBy(...clauses: (string | Column<any> | SQL)[]): this;
|
|
120
212
|
limit(value: number): this;
|
|
121
213
|
offset(value: number): this;
|
|
122
214
|
execute(): Promise<T[]>;
|
|
215
|
+
iterator(): Promise<AsyncIterableIterator<T>>;
|
|
123
216
|
}
|
|
124
217
|
declare class TauriORM {
|
|
125
218
|
query: Record<string, any>;
|
|
@@ -130,25 +223,76 @@ declare class TauriORM {
|
|
|
130
223
|
private getDb;
|
|
131
224
|
configureQuery(tables: Record<string, Table<any>>, relations: Record<string, Record<string, RelationConfig>>): void;
|
|
132
225
|
select<T>(fields?: Record<string, Column<any>>): SelectQueryBuilder<T>;
|
|
226
|
+
selectDistinct<T>(fields?: Record<string, Column<any>>): SelectQueryBuilder<T>;
|
|
133
227
|
insert(table: Table<any>): {
|
|
134
228
|
_table: any;
|
|
135
229
|
_rows: Record<string, any>[];
|
|
230
|
+
_selectSql: {
|
|
231
|
+
clause: string;
|
|
232
|
+
bindings: any[];
|
|
233
|
+
} | null;
|
|
234
|
+
_conflict: null | {
|
|
235
|
+
kind: "doNothing";
|
|
236
|
+
target?: string | string[];
|
|
237
|
+
where?: SQL;
|
|
238
|
+
} | {
|
|
239
|
+
kind: "doUpdate";
|
|
240
|
+
target: string | string[];
|
|
241
|
+
targetWhere?: SQL;
|
|
242
|
+
set: Record<string, any>;
|
|
243
|
+
setWhere?: SQL;
|
|
244
|
+
};
|
|
245
|
+
_returning: null | "__RETURNING_ID__" | Record<string, Column<any>>;
|
|
136
246
|
values(rowOrRows: Record<string, any> | Record<string, any>[]): /*elided*/ any;
|
|
137
|
-
|
|
247
|
+
select(qb: {
|
|
248
|
+
toSQL?: () => {
|
|
249
|
+
clause: string;
|
|
250
|
+
bindings: any[];
|
|
251
|
+
};
|
|
252
|
+
} | SQL): /*elided*/ any;
|
|
253
|
+
returning(fields?: Record<string, Column<any>>): any;
|
|
254
|
+
$returningId(): any;
|
|
255
|
+
onConflictDoNothing(opts?: {
|
|
256
|
+
target?: Column<any> | Column<any>[];
|
|
257
|
+
where?: SQL;
|
|
258
|
+
}): /*elided*/ any;
|
|
259
|
+
onConflictDoUpdate(opts: {
|
|
260
|
+
target: Column<any> | Column<any>[];
|
|
261
|
+
targetWhere?: SQL;
|
|
262
|
+
set: Record<string, any>;
|
|
263
|
+
setWhere?: SQL;
|
|
264
|
+
}): /*elided*/ any;
|
|
265
|
+
execute(): Promise<any>;
|
|
266
|
+
_buildConflictClause(): string;
|
|
267
|
+
_executeWithReturning(db: any, query: string, bindings: any[]): Promise<any>;
|
|
138
268
|
};
|
|
139
269
|
update(table: Table<any>): {
|
|
140
270
|
_table: any;
|
|
141
271
|
_data: Record<string, any> | null;
|
|
142
272
|
_where: Record<string, any> | SQL | null;
|
|
273
|
+
_orderBy: Array<string | SQL>;
|
|
274
|
+
_limit: number | null;
|
|
275
|
+
_from: Table<any> | null;
|
|
276
|
+
_returning: null | Record<string, Column<any>>;
|
|
143
277
|
set(data: Record<string, any>): /*elided*/ any;
|
|
144
278
|
where(cond: Record<string, any> | SQL): /*elided*/ any;
|
|
145
|
-
|
|
279
|
+
orderBy(...clauses: (string | Column<any> | SQL)[]): /*elided*/ any;
|
|
280
|
+
limit(n: number): /*elided*/ any;
|
|
281
|
+
from(tbl: Table<any>): /*elided*/ any;
|
|
282
|
+
returning(fields?: Record<string, Column<any>>): any;
|
|
283
|
+
execute(): Promise<unknown>;
|
|
146
284
|
};
|
|
147
285
|
delete(table: Table<any>): {
|
|
148
286
|
_table: any;
|
|
149
287
|
_where: Record<string, any> | SQL | null;
|
|
288
|
+
_orderBy: Array<string | SQL>;
|
|
289
|
+
_limit: number | null;
|
|
290
|
+
_returning: null | Record<string, Column<any>>;
|
|
150
291
|
where(cond: Record<string, any> | SQL): /*elided*/ any;
|
|
151
|
-
|
|
292
|
+
orderBy(...clauses: (string | Column<any> | SQL)[]): /*elided*/ any;
|
|
293
|
+
limit(n: number): /*elided*/ any;
|
|
294
|
+
returning(fields?: Record<string, Column<any>>): any;
|
|
295
|
+
execute(): Promise<unknown>;
|
|
152
296
|
};
|
|
153
297
|
run(query: string, bindings?: any[]): Promise<void>;
|
|
154
298
|
private generateCreateTableSql;
|
|
@@ -262,4 +406,4 @@ declare function makeQueryAPI(tables: Record<string, Table<any>>, relDefs: Recor
|
|
|
262
406
|
}) => Promise<any | null>;
|
|
263
407
|
}; };
|
|
264
408
|
|
|
265
|
-
export { type BlobMode, type Column, type ColumnBuilder, type IntegerMode, type ManyRelation, type NumericMode, type OneRelation, type SQL, type SQLExpression, type Table, TauriORM, type UpdateDeleteAction, asc, blob, boolean, defineTable, desc, eq, gt, gte, increments, integer, like, lt, lte, makeQueryAPI, ne, numeric, real, relations, sql, text, timestamp };
|
|
409
|
+
export { type BlobMode, type CheckSpec, type Column, type ColumnBuilder, type ForeignKeySpec, type IndexSpec, type IntegerMode, type ManyRelation, type NumericMode, type OneRelation, type PrimaryKeySpec, type SQL, type SQLExpression, type Table, TauriORM, type UniqueSpec, type UpdateDeleteAction, and, asc, between, blob, boolean, check, defineTable, desc, eq, exists, foreignKey, getQualifiedName, gt, gte, ilike, inArray, increments, index, integer, isNotNull, isNull, like, lt, lte, makeQueryAPI, ne, not, notBetween, notExists, notIlike, notInArray, numeric, or, primaryKey, raw, real, relations, sql, text, timestamp, unique, uniqueIndex };
|