@type32/tauri-sqlite-orm 0.1.13 → 0.1.15

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/dist/index.d.mts CHANGED
@@ -194,6 +194,31 @@ type InferInsert<T> = T extends {
194
194
  type InferSelect<T> = T extends {
195
195
  $inferSelect: infer S;
196
196
  } ? S : never;
197
+ type WithSpec = Record<string, boolean | {
198
+ with?: WithSpec;
199
+ columns?: string[];
200
+ }>;
201
+ type FindManyOptions<TTable extends Table<any>> = {
202
+ with?: WithSpec;
203
+ join?: boolean;
204
+ columns?: (keyof InferSelect<TTable>)[] | Record<keyof InferSelect<TTable>, boolean>;
205
+ where?: SQL | Partial<InferSelect<TTable>> | ((table: TTable, ops: {
206
+ eq: typeof eq;
207
+ ne: typeof ne;
208
+ gt: typeof gt;
209
+ gte: typeof gte;
210
+ lt: typeof lt;
211
+ lte: typeof lte;
212
+ like: typeof like;
213
+ }) => SQL);
214
+ orderBy?: (keyof InferSelect<TTable>)[] | ((table: TTable, ops: {
215
+ asc: typeof asc;
216
+ desc: typeof desc;
217
+ }) => (string | SQL)[]);
218
+ limit?: number;
219
+ offset?: number;
220
+ };
221
+ type FindFirstOptions<TTable extends Table<any>> = Omit<FindManyOptions<TTable>, "limit" | "offset">;
197
222
  declare class SelectQueryBuilder<T> {
198
223
  private _table;
199
224
  private _selectedColumns;
@@ -323,8 +348,8 @@ declare class TauriORM {
323
348
  configure<TTables extends Record<string, Table<any>>, TRelDefs extends Record<string, Record<string, RelationConfig>> = Record<string, Record<string, RelationConfig>>>(tables: TTables, relDefs?: TRelDefs): this & {
324
349
  query: {
325
350
  [K in keyof TTables]: {
326
- findMany: (opts?: any) => Promise<Array<InferSelect<TTables[K]>>>;
327
- findFirst: (opts?: any) => Promise<InferSelect<TTables[K]> | null>;
351
+ findMany: (opts?: FindManyOptions<TTables[K]>) => Promise<Array<InferSelect<TTables[K]>>>;
352
+ findFirst: (opts?: FindFirstOptions<TTables[K]>) => Promise<InferSelect<TTables[K]> | null>;
328
353
  };
329
354
  };
330
355
  };
@@ -414,10 +439,6 @@ type ManyRelation = {
414
439
  };
415
440
  declare function relations(baseTable: Table<any>, builder: (ctx: RelationBuilderCtx) => Record<string, OneRelation | ManyRelation>): Record<string, OneRelation | ManyRelation>;
416
441
  type RelationConfig = OneRelation | ManyRelation;
417
- type WithSpec = Record<string, boolean | {
418
- with?: WithSpec;
419
- columns?: string[];
420
- }>;
421
442
  declare function makeQueryAPI(tables: Record<string, Table<any>>, relDefs: Record<string, Record<string, RelationConfig>>, dbProvider: () => Promise<Database>): { [K in keyof typeof tables]: {
422
443
  findMany: (opts?: {
423
444
  with?: WithSpec;
package/dist/index.d.ts CHANGED
@@ -194,6 +194,31 @@ type InferInsert<T> = T extends {
194
194
  type InferSelect<T> = T extends {
195
195
  $inferSelect: infer S;
196
196
  } ? S : never;
197
+ type WithSpec = Record<string, boolean | {
198
+ with?: WithSpec;
199
+ columns?: string[];
200
+ }>;
201
+ type FindManyOptions<TTable extends Table<any>> = {
202
+ with?: WithSpec;
203
+ join?: boolean;
204
+ columns?: (keyof InferSelect<TTable>)[] | Record<keyof InferSelect<TTable>, boolean>;
205
+ where?: SQL | Partial<InferSelect<TTable>> | ((table: TTable, ops: {
206
+ eq: typeof eq;
207
+ ne: typeof ne;
208
+ gt: typeof gt;
209
+ gte: typeof gte;
210
+ lt: typeof lt;
211
+ lte: typeof lte;
212
+ like: typeof like;
213
+ }) => SQL);
214
+ orderBy?: (keyof InferSelect<TTable>)[] | ((table: TTable, ops: {
215
+ asc: typeof asc;
216
+ desc: typeof desc;
217
+ }) => (string | SQL)[]);
218
+ limit?: number;
219
+ offset?: number;
220
+ };
221
+ type FindFirstOptions<TTable extends Table<any>> = Omit<FindManyOptions<TTable>, "limit" | "offset">;
197
222
  declare class SelectQueryBuilder<T> {
198
223
  private _table;
199
224
  private _selectedColumns;
@@ -323,8 +348,8 @@ declare class TauriORM {
323
348
  configure<TTables extends Record<string, Table<any>>, TRelDefs extends Record<string, Record<string, RelationConfig>> = Record<string, Record<string, RelationConfig>>>(tables: TTables, relDefs?: TRelDefs): this & {
324
349
  query: {
325
350
  [K in keyof TTables]: {
326
- findMany: (opts?: any) => Promise<Array<InferSelect<TTables[K]>>>;
327
- findFirst: (opts?: any) => Promise<InferSelect<TTables[K]> | null>;
351
+ findMany: (opts?: FindManyOptions<TTables[K]>) => Promise<Array<InferSelect<TTables[K]>>>;
352
+ findFirst: (opts?: FindFirstOptions<TTables[K]>) => Promise<InferSelect<TTables[K]> | null>;
328
353
  };
329
354
  };
330
355
  };
@@ -414,10 +439,6 @@ type ManyRelation = {
414
439
  };
415
440
  declare function relations(baseTable: Table<any>, builder: (ctx: RelationBuilderCtx) => Record<string, OneRelation | ManyRelation>): Record<string, OneRelation | ManyRelation>;
416
441
  type RelationConfig = OneRelation | ManyRelation;
417
- type WithSpec = Record<string, boolean | {
418
- with?: WithSpec;
419
- columns?: string[];
420
- }>;
421
442
  declare function makeQueryAPI(tables: Record<string, Table<any>>, relDefs: Record<string, Record<string, RelationConfig>>, dbProvider: () => Promise<Database>): { [K in keyof typeof tables]: {
422
443
  findMany: (opts?: {
423
444
  with?: WithSpec;
package/dist/index.js CHANGED
@@ -273,7 +273,7 @@ function defineTable(tableName, schema, extras) {
273
273
  col.tableName = tableName;
274
274
  }
275
275
  const table = {
276
- _tableName: tableName,
276
+ tableName,
277
277
  _schema: finalizedSchema,
278
278
  _constraints: [],
279
279
  _indexes: [],
package/dist/index.mjs CHANGED
@@ -195,7 +195,7 @@ function defineTable(tableName, schema, extras) {
195
195
  col.tableName = tableName;
196
196
  }
197
197
  const table = {
198
- _tableName: tableName,
198
+ tableName,
199
199
  _schema: finalizedSchema,
200
200
  _constraints: [],
201
201
  _indexes: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@type32/tauri-sqlite-orm",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "A Drizzle-like ORM for Tauri v2's SQL JS API plugin.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",