rado 0.1.8 → 0.1.9

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/Query.d.ts CHANGED
@@ -1,107 +1,107 @@
1
- import { ColumnData } from './Column';
2
- import { ExprData } from './Expr';
3
- import { OrderBy } from './OrderBy';
4
- import { Index, Schema } from './Schema';
5
- import { Target } from './Target';
6
- export declare enum QueryType {
7
- Insert = "Insert",
8
- Select = "Select",
9
- Update = "Update",
10
- Delete = "Delete",
11
- CreateTable = "CreateTable",
12
- CreateIndex = "CreateIndex",
13
- DropIndex = "DropIndex",
14
- AlterTable = "AlterTable",
15
- Batch = "Batch",
16
- Transaction = "Transaction",
17
- Raw = "Raw"
18
- }
19
- export type Query<T = any> = Query.Insert | Query.Select | Query.Update | Query.Delete | Query.CreateTable | Query.CreateIndex | Query.DropIndex | Query.AlterTable | Query.Batch | Query.Transaction | Query.Raw;
20
- export declare namespace Query {
21
- interface QueryBase {
22
- limit?: number;
23
- offset?: number;
24
- type: QueryType;
25
- where?: ExprData;
26
- orderBy?: Array<OrderBy>;
27
- groupBy?: Array<ExprData>;
28
- having?: ExprData;
29
- selection?: ExprData;
30
- singleResult?: boolean;
31
- }
32
- interface Insert extends QueryBase {
33
- type: QueryType.Insert;
34
- into: Schema;
35
- data: Array<any>;
36
- }
37
- function Insert(insert: Omit<Insert, 'type'>): Query.Insert;
38
- interface Select extends QueryBase {
39
- type: QueryType.Select;
40
- selection: ExprData;
41
- from: Target;
42
- }
43
- function Select(select: Omit<Select, 'type'>): Query.Select;
44
- interface Update extends QueryBase {
45
- type: QueryType.Update;
46
- table: Schema;
47
- set?: Record<string, any>;
48
- }
49
- function Update(update: Omit<Update, 'type'>): Query.Update;
50
- interface Delete extends QueryBase {
51
- type: QueryType.Delete;
52
- table: Schema;
53
- }
54
- function Delete(del: Omit<Delete, 'type'>): Query.Delete;
55
- interface CreateTable extends QueryBase {
56
- type: QueryType.CreateTable;
57
- table: Schema;
58
- ifNotExists?: boolean;
59
- }
60
- function CreateTable(create: Omit<CreateTable, 'type'>): Query.CreateTable;
61
- interface CreateIndex extends QueryBase {
62
- type: QueryType.CreateIndex;
63
- table: Schema;
64
- index: Index;
65
- ifNotExists?: boolean;
66
- }
67
- function CreateIndex(create: Omit<CreateIndex, 'type'>): Query.CreateIndex;
68
- interface DropIndex extends QueryBase {
69
- type: QueryType.DropIndex;
70
- table: Schema;
71
- name: string;
72
- ifExists?: boolean;
73
- }
74
- function DropIndex(drop: Omit<DropIndex, 'type'>): Query.DropIndex;
75
- interface Batch extends QueryBase {
76
- type: QueryType.Batch;
77
- queries: Array<Query<any>>;
78
- }
79
- function Batch(batch: Omit<Batch, 'type'>): Query.Batch;
80
- enum TransactionOperation {
81
- Begin = "Begin",
82
- Commit = "Commit",
83
- Rollback = "Rollback"
84
- }
85
- interface Transaction extends QueryBase {
86
- type: QueryType.Transaction;
87
- id: string;
88
- op: TransactionOperation;
89
- }
90
- function Transaction(transaction: Omit<Transaction, 'type'>): Query.Transaction;
91
- type RawReturn = 'row' | 'rows' | undefined;
92
- interface Raw extends QueryBase {
93
- type: QueryType.Raw;
94
- expectedReturn?: 'row' | 'rows';
95
- strings: ReadonlyArray<string>;
96
- params: Array<any>;
97
- }
98
- function Raw(raw: Omit<Raw, 'type'>): Query.Raw;
99
- interface AlterTable extends QueryBase {
100
- type: QueryType.AlterTable;
101
- table: Schema;
102
- alterColumn?: ColumnData;
103
- addColumn?: ColumnData;
104
- dropColumn?: string;
105
- }
106
- function AlterTable(alter: Omit<AlterTable, 'type'>): Query.AlterTable;
107
- }
1
+ import { ColumnData } from './Column';
2
+ import { ExprData } from './Expr';
3
+ import { OrderBy } from './OrderBy';
4
+ import { Index, Schema } from './Schema';
5
+ import { Target } from './Target';
6
+ export declare enum QueryType {
7
+ Insert = "Insert",
8
+ Select = "Select",
9
+ Update = "Update",
10
+ Delete = "Delete",
11
+ CreateTable = "CreateTable",
12
+ CreateIndex = "CreateIndex",
13
+ DropIndex = "DropIndex",
14
+ AlterTable = "AlterTable",
15
+ Batch = "Batch",
16
+ Transaction = "Transaction",
17
+ Raw = "Raw"
18
+ }
19
+ export type Query<T = any> = Query.Insert | Query.Select | Query.Update | Query.Delete | Query.CreateTable | Query.CreateIndex | Query.DropIndex | Query.AlterTable | Query.Batch | Query.Transaction | Query.Raw;
20
+ export declare namespace Query {
21
+ interface QueryBase {
22
+ limit?: number;
23
+ offset?: number;
24
+ type: QueryType;
25
+ where?: ExprData;
26
+ orderBy?: Array<OrderBy>;
27
+ groupBy?: Array<ExprData>;
28
+ having?: ExprData;
29
+ selection?: ExprData;
30
+ singleResult?: boolean;
31
+ }
32
+ interface Insert extends QueryBase {
33
+ type: QueryType.Insert;
34
+ into: Schema;
35
+ data: Array<any>;
36
+ }
37
+ function Insert(insert: Omit<Insert, 'type'>): Query.Insert;
38
+ interface Select extends QueryBase {
39
+ type: QueryType.Select;
40
+ selection: ExprData;
41
+ from: Target;
42
+ }
43
+ function Select(select: Omit<Select, 'type'>): Query.Select;
44
+ interface Update extends QueryBase {
45
+ type: QueryType.Update;
46
+ table: Schema;
47
+ set?: Record<string, any>;
48
+ }
49
+ function Update(update: Omit<Update, 'type'>): Query.Update;
50
+ interface Delete extends QueryBase {
51
+ type: QueryType.Delete;
52
+ table: Schema;
53
+ }
54
+ function Delete(del: Omit<Delete, 'type'>): Query.Delete;
55
+ interface CreateTable extends QueryBase {
56
+ type: QueryType.CreateTable;
57
+ table: Schema;
58
+ ifNotExists?: boolean;
59
+ }
60
+ function CreateTable(create: Omit<CreateTable, 'type'>): Query.CreateTable;
61
+ interface CreateIndex extends QueryBase {
62
+ type: QueryType.CreateIndex;
63
+ table: Schema;
64
+ index: Index;
65
+ ifNotExists?: boolean;
66
+ }
67
+ function CreateIndex(create: Omit<CreateIndex, 'type'>): Query.CreateIndex;
68
+ interface DropIndex extends QueryBase {
69
+ type: QueryType.DropIndex;
70
+ table: Schema;
71
+ name: string;
72
+ ifExists?: boolean;
73
+ }
74
+ function DropIndex(drop: Omit<DropIndex, 'type'>): Query.DropIndex;
75
+ interface Batch extends QueryBase {
76
+ type: QueryType.Batch;
77
+ queries: Array<Query<any>>;
78
+ }
79
+ function Batch(batch: Omit<Batch, 'type'>): Query.Batch;
80
+ enum TransactionOperation {
81
+ Begin = "Begin",
82
+ Commit = "Commit",
83
+ Rollback = "Rollback"
84
+ }
85
+ interface Transaction extends QueryBase {
86
+ type: QueryType.Transaction;
87
+ id: string;
88
+ op: TransactionOperation;
89
+ }
90
+ function Transaction(transaction: Omit<Transaction, 'type'>): Query.Transaction;
91
+ type RawReturn = 'row' | 'rows' | undefined;
92
+ interface Raw extends QueryBase {
93
+ type: QueryType.Raw;
94
+ expectedReturn?: 'row' | 'rows';
95
+ strings: ReadonlyArray<string>;
96
+ params: Array<any>;
97
+ }
98
+ function Raw(raw: Omit<Raw, 'type'>): Query.Raw;
99
+ interface AlterTable extends QueryBase {
100
+ type: QueryType.AlterTable;
101
+ table: Schema;
102
+ alterColumn?: ColumnData;
103
+ addColumn?: ColumnData;
104
+ dropColumn?: string;
105
+ }
106
+ function AlterTable(alter: Omit<AlterTable, 'type'>): Query.AlterTable;
107
+ }
@@ -1,4 +1,4 @@
1
- export interface Sanitizer {
2
- escapeValue(value: any): string;
3
- escapeIdentifier(ident: string): string;
4
- }
1
+ export interface Sanitizer {
2
+ escapeValue(value: any): string;
3
+ escapeIdentifier(ident: string): string;
4
+ }
package/dist/Schema.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- import { ColumnData } from './Column';
2
- import { ExprData } from './Expr';
3
- import { Formatter } from './Formatter';
4
- import { Query } from './Query';
5
- export interface Index {
6
- name: string;
7
- on: Array<ExprData>;
8
- where?: ExprData;
9
- }
10
- export interface Schema {
11
- name: string;
12
- alias?: string;
13
- columns: Record<string, ColumnData>;
14
- indexes: Record<string, Index>;
15
- }
16
- export interface SchemaInstructions {
17
- columns: Record<string, string>;
18
- indexes: Record<string, string>;
19
- }
20
- export declare namespace Schema {
21
- function create(schema: Schema): Query.Batch;
22
- function upgrade(formatter: Formatter, local: SchemaInstructions, schema: Schema): Array<Query>;
23
- }
1
+ import { ColumnData } from './Column';
2
+ import { ExprData } from './Expr';
3
+ import { Formatter } from './Formatter';
4
+ import { Query } from './Query';
5
+ export interface Index {
6
+ name: string;
7
+ on: Array<ExprData>;
8
+ where?: ExprData;
9
+ }
10
+ export interface Schema {
11
+ name: string;
12
+ alias?: string;
13
+ columns: Record<string, ColumnData>;
14
+ indexes: Record<string, Index>;
15
+ }
16
+ export interface SchemaInstructions {
17
+ columns: Record<string, string>;
18
+ indexes: Record<string, string>;
19
+ }
20
+ export declare namespace Schema {
21
+ function create(schema: Schema): Query.Batch;
22
+ function upgrade(formatter: Formatter, local: SchemaInstructions, schema: Schema): Array<Query>;
23
+ }
@@ -1,20 +1,20 @@
1
- import type { Cursor } from './Cursor';
2
- import type { Expr } from './Expr';
3
- type SelectionBase = Expr<any> | Cursor.SelectMultiple<any> | Cursor.SelectSingle<any>;
4
- interface SelectionRecord extends Record<string, Selection> {
5
- }
6
- export type Selection = SelectionBase | SelectionRecord;
7
- export declare namespace Selection {
8
- const __tableType: unique symbol;
9
- const __cursorType: unique symbol;
10
- type Infer<T> = T extends {
11
- [__tableType](): infer K;
12
- } ? K : T extends {
13
- [__cursorType](): infer K;
14
- } ? K : T extends Expr<infer K> ? K : T extends Record<string, Selection> ? {
15
- [K in keyof T]: Infer<T[K]>;
16
- } : T;
17
- type With<A, B> = Expr<Combine<A, B>>;
18
- type Combine<A, B> = Omit<A, keyof Infer<B>> & Infer<B>;
19
- }
20
- export {};
1
+ import type { Cursor } from './Cursor';
2
+ import type { Expr } from './Expr';
3
+ type SelectionBase = Expr<any> | Cursor.SelectMultiple<any> | Cursor.SelectSingle<any>;
4
+ interface SelectionRecord extends Record<string, Selection> {
5
+ }
6
+ export type Selection = SelectionBase | SelectionRecord;
7
+ export declare namespace Selection {
8
+ const __tableType: unique symbol;
9
+ const __cursorType: unique symbol;
10
+ type Infer<T> = T extends {
11
+ [__tableType](): infer K;
12
+ } ? K : T extends {
13
+ [__cursorType](): infer K;
14
+ } ? K : T extends Expr<infer K> ? K : T extends Record<string, Selection> ? {
15
+ [K in keyof T]: Infer<T[K]>;
16
+ } : T;
17
+ type With<A, B> = Expr<Combine<A, B>>;
18
+ type Combine<A, B> = Omit<A, keyof Infer<B>> & Infer<B>;
19
+ }
20
+ export {};
@@ -1,57 +1,57 @@
1
- import { Sanitizer } from './Sanitizer';
2
- declare enum TokenType {
3
- Raw = "Raw",
4
- Identifier = "Identifier",
5
- Value = "Value",
6
- Indent = "Indent",
7
- Dedent = "Dedent"
8
- }
9
- declare class Token {
10
- type: TokenType;
11
- data: any;
12
- constructor(type: TokenType, data: any);
13
- static Raw(data: string): Token;
14
- static Indent(): Token;
15
- static Dedent(): Token;
16
- static Identifier(data: string): Token;
17
- static Value(data: any): Token;
18
- }
19
- export declare class Statement {
20
- tokens: Array<Token>;
21
- constructor(tokens: Array<Token>);
22
- concat(...tokens: Array<Token | Statement>): Statement;
23
- static create(from: string | Statement): Statement;
24
- static tag(strings: ReadonlyArray<string>, ...params: Array<any>): Statement;
25
- space(): Statement;
26
- call(method: string, ...args: Array<Statement>): Statement;
27
- addCall(method: string, ...args: Array<Statement>): Statement;
28
- add(addition: undefined | string | Statement): Statement;
29
- addLine(addition: undefined | string | Statement): Statement;
30
- addIf(condition: any, addition: string | Statement | (() => string | Statement)): Statement;
31
- indent(): Statement;
32
- dedent(): Statement;
33
- newline(): Statement;
34
- identifier(name: string): Statement;
35
- addIdentifier(name: string): Statement;
36
- value(value: any): Statement;
37
- addValue(value: any): Statement;
38
- raw(query: string): Statement;
39
- parenthesis(inner: string | Statement): Statement;
40
- addParenthesis(stmnt: string | Statement): Statement;
41
- separated(input: Array<Statement>, separator?: string): Statement;
42
- addSeparated(input: Array<Statement>, separator?: string): Statement;
43
- isEmpty(): boolean;
44
- compile(sanitizer: Sanitizer, formatInline?: boolean): Statement.Compiled;
45
- }
46
- export declare namespace Statement {
47
- type Compiled = [sql: string, params: Array<any>];
48
- }
49
- export declare function newline(): Statement;
50
- export declare function raw(raw: string): Statement;
51
- export declare function identifier(name: string): Statement;
52
- export declare function value(value: any): Statement;
53
- export declare function empty(): Statement;
54
- export declare function parenthesis(stmnt: Statement): Statement;
55
- export declare function call(method: string, ...args: Array<Statement>): Statement;
56
- export declare function separated(input: Array<Statement>, separator?: string): Statement;
57
- export {};
1
+ import { Sanitizer } from './Sanitizer';
2
+ declare enum TokenType {
3
+ Raw = "Raw",
4
+ Identifier = "Identifier",
5
+ Value = "Value",
6
+ Indent = "Indent",
7
+ Dedent = "Dedent"
8
+ }
9
+ declare class Token {
10
+ type: TokenType;
11
+ data: any;
12
+ constructor(type: TokenType, data: any);
13
+ static Raw(data: string): Token;
14
+ static Indent(): Token;
15
+ static Dedent(): Token;
16
+ static Identifier(data: string): Token;
17
+ static Value(data: any): Token;
18
+ }
19
+ export declare class Statement {
20
+ tokens: Array<Token>;
21
+ constructor(tokens: Array<Token>);
22
+ concat(...tokens: Array<Token | Statement>): Statement;
23
+ static create(from: string | Statement): Statement;
24
+ static tag(strings: ReadonlyArray<string>, ...params: Array<any>): Statement;
25
+ space(): Statement;
26
+ call(method: string, ...args: Array<Statement>): Statement;
27
+ addCall(method: string, ...args: Array<Statement>): Statement;
28
+ add(addition: undefined | string | Statement): Statement;
29
+ addLine(addition: undefined | string | Statement): Statement;
30
+ addIf(condition: any, addition: string | Statement | (() => string | Statement)): Statement;
31
+ indent(): Statement;
32
+ dedent(): Statement;
33
+ newline(): Statement;
34
+ identifier(name: string): Statement;
35
+ addIdentifier(name: string): Statement;
36
+ value(value: any): Statement;
37
+ addValue(value: any): Statement;
38
+ raw(query: string): Statement;
39
+ parenthesis(inner: string | Statement): Statement;
40
+ addParenthesis(stmnt: string | Statement): Statement;
41
+ separated(input: Array<Statement>, separator?: string): Statement;
42
+ addSeparated(input: Array<Statement>, separator?: string): Statement;
43
+ isEmpty(): boolean;
44
+ compile(sanitizer: Sanitizer, formatInline?: boolean): Statement.Compiled;
45
+ }
46
+ export declare namespace Statement {
47
+ type Compiled = [sql: string, params: Array<any>];
48
+ }
49
+ export declare function newline(): Statement;
50
+ export declare function raw(raw: string): Statement;
51
+ export declare function identifier(name: string): Statement;
52
+ export declare function value(value: any): Statement;
53
+ export declare function empty(): Statement;
54
+ export declare function parenthesis(stmnt: Statement): Statement;
55
+ export declare function call(method: string, ...args: Array<Statement>): Statement;
56
+ export declare function separated(input: Array<Statement>, separator?: string): Statement;
57
+ export {};
package/dist/Table.d.ts CHANGED
@@ -1,50 +1,56 @@
1
- import { Column } from './Column';
2
- import { Cursor } from './Cursor';
3
- import { Expr } from './Expr';
4
- import { Fields } from './Fields';
5
- import { Schema } from './Schema';
6
- import { Selection } from './Selection';
7
- import { Update } from './Update';
8
- export declare class Table<T> extends Cursor.SelectMultiple<T> {
9
- [Selection.__tableType](): T;
10
- constructor(schema: Schema);
11
- insertOne(record: Table.Insert<T>): Cursor.Batch<T>;
12
- insertAll(data: Array<Table.Insert<T>>): Cursor.InsertValues;
13
- set(data: Update<T>): Cursor.Update<T>;
14
- createTable(): Cursor.Create;
15
- as(alias: string): Table<T> & Fields<T>;
16
- get(name: string): Expr<any>;
17
- toExpr(): Expr<T>;
18
- schema(): Schema;
19
- }
20
- export declare namespace Table {
21
- type Intersection<A, B> = A & B extends infer U ? {
22
- [P in keyof U]: U[P];
23
- } : never;
24
- type OptionalKeys<T> = {
25
- [K in keyof T]: null extends T[K] ? K : T[K] extends Column.Optional ? K : never;
26
- }[keyof T];
27
- type RequiredKeys<T> = {
28
- [K in keyof T]: null extends T[K] ? never : T[K] extends Column.Optional ? never : K;
29
- }[keyof T];
30
- type Optionals<T> = {
31
- [K in keyof T]?: T[K] extends Column.Optional & infer V ? V : T[K];
32
- };
33
- export type Insert<T> = Intersection<Optionals<Pick<T, OptionalKeys<T>>>, Pick<T, RequiredKeys<T>>>;
34
- export {};
35
- }
36
- export interface TableOptions<T> {
37
- name: string;
38
- alias?: string;
39
- columns: {
40
- [K in keyof T]: Column<T[K]>;
41
- };
42
- indexes?: (this: Fields<T>) => Record<string, {
43
- on: Array<Expr<any>>;
44
- where?: Expr<boolean>;
45
- }>;
46
- }
47
- export declare function table<T extends {}>(options: TableOptions<T>): Table<T> & Fields<T>;
48
- export declare namespace table {
49
- type infer<T> = T extends Table<infer U> ? U : never;
50
- }
1
+ import { Column } from './Column';
2
+ import { Cursor } from './Cursor';
3
+ import { Expr } from './Expr';
4
+ import { Fields } from './Fields';
5
+ import { Schema } from './Schema';
6
+ import { Selection } from './Selection';
7
+ import { Update } from './Update';
8
+ export declare class Table<T> extends Cursor.SelectMultiple<Table.Normalize<T>> {
9
+ [Selection.__tableType](): Table.Normalize<T>;
10
+ constructor(schema: Schema);
11
+ insertOne(record: Table.Insert<T>): Cursor.Batch<Table.Normalize<T>>;
12
+ insertAll(data: Array<Table.Insert<T>>): Cursor.InsertValues;
13
+ set(data: Update<Table.Normalize<T>>): Cursor.Update<Table.Normalize<T>>;
14
+ createTable(): Cursor.Create;
15
+ as(alias: string): Table<T> & Fields<T>;
16
+ get(name: string): Expr<any>;
17
+ toExpr(): Expr<Table.Normalize<T>>;
18
+ schema(): Schema;
19
+ }
20
+ export declare namespace Table {
21
+ type Intersection<A, B> = A & B extends infer U ? {
22
+ [P in keyof U]: U[P];
23
+ } : never;
24
+ type OptionalKeys<T> = {
25
+ [K in keyof T]: null extends T[K] ? K : T[K] extends Column.Primary<any, any> ? K : T[K] extends Column.Optional<any> ? K : never;
26
+ }[keyof T];
27
+ type RequiredKeys<T> = {
28
+ [K in keyof T]: null extends T[K] ? never : T[K] extends Column.Primary<any, any> ? never : T[K] extends Column.Optional<any> ? never : K;
29
+ }[keyof T];
30
+ type Optionals<T> = {
31
+ [K in keyof T]?: T[K] extends Column.Optional<infer V> ? V : T[K];
32
+ };
33
+ export type Insert<T> = Intersection<Optionals<Pick<T, OptionalKeys<T>>>, Pick<T, RequiredKeys<T>>>;
34
+ export type Normalize<T> = {
35
+ [K in keyof T]: T[K] extends Column.Optional<infer V> ? V : T[K] extends Column.Primary<infer K, infer V> ? string extends K ? V : V & {
36
+ [Column.isPrimary]: K;
37
+ } : T[K];
38
+ };
39
+ export type Infer<T> = T extends Table<infer U> ? Normalize<U> : never;
40
+ export {};
41
+ }
42
+ export interface TableOptions<T> {
43
+ name: string;
44
+ alias?: string;
45
+ columns: {
46
+ [K in keyof T]: Column<T[K]>;
47
+ };
48
+ indexes?: (this: Fields<T>) => Record<string, {
49
+ on: Array<Expr<any>>;
50
+ where?: Expr<boolean>;
51
+ }>;
52
+ }
53
+ export declare function table<T extends {}>(options: TableOptions<T>): Table<T> & Fields<T>;
54
+ export declare namespace table {
55
+ type infer<T> = Table.Infer<T>;
56
+ }
package/dist/Table.js CHANGED
@@ -62,7 +62,9 @@ var Table = class extends Cursor.SelectMultiple {
62
62
  return new Expr(ExprData.Field(this.toExpr().expr, name));
63
63
  }
64
64
  toExpr() {
65
- return new Expr(ExprData.Row(Target.Table(this.schema())));
65
+ return new Expr(
66
+ ExprData.Row(Target.Table(this.schema()))
67
+ );
66
68
  }
67
69
  schema() {
68
70
  throw new Error("Not implemented");
package/dist/Target.d.ts CHANGED
@@ -1,30 +1,30 @@
1
- import { ExprData } from './Expr';
2
- import { Schema } from './Schema';
3
- export declare enum TargetType {
4
- Each = "Each",
5
- Table = "Table",
6
- Join = "Join"
7
- }
8
- export type Target = Target.Each | Target.Table | Target.Join;
9
- export declare namespace Target {
10
- interface Each {
11
- type: TargetType.Each;
12
- expr: ExprData;
13
- alias: string;
14
- }
15
- function Each(expr: ExprData, alias: string): Each;
16
- interface Table {
17
- type: TargetType.Table;
18
- table: Schema;
19
- }
20
- function Table(table: Schema): Table;
21
- interface Join {
22
- type: TargetType.Join;
23
- left: Target;
24
- right: Target;
25
- joinType: 'left' | 'inner';
26
- on: ExprData;
27
- }
28
- function Join(left: Target, right: Target, joinType: 'left' | 'inner', on: ExprData): Join;
29
- function source(from: Target): Schema | undefined;
30
- }
1
+ import { ExprData } from './Expr';
2
+ import { Schema } from './Schema';
3
+ export declare enum TargetType {
4
+ Each = "Each",
5
+ Table = "Table",
6
+ Join = "Join"
7
+ }
8
+ export type Target = Target.Each | Target.Table | Target.Join;
9
+ export declare namespace Target {
10
+ interface Each {
11
+ type: TargetType.Each;
12
+ expr: ExprData;
13
+ alias: string;
14
+ }
15
+ function Each(expr: ExprData, alias: string): Each;
16
+ interface Table {
17
+ type: TargetType.Table;
18
+ table: Schema;
19
+ }
20
+ function Table(table: Schema): Table;
21
+ interface Join {
22
+ type: TargetType.Join;
23
+ left: Target;
24
+ right: Target;
25
+ joinType: 'left' | 'inner';
26
+ on: ExprData;
27
+ }
28
+ function Join(left: Target, right: Target, joinType: 'left' | 'inner', on: ExprData): Join;
29
+ function source(from: Target): Schema | undefined;
30
+ }
package/dist/Update.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { EV } from './Expr';
2
- export type Update<Row> = Partial<{
3
- [K in keyof Row]: EV<Row[K]>;
4
- }>;
1
+ import type { EV } from './Expr';
2
+ export type Update<Row> = Partial<{
3
+ [K in keyof Row]: EV<Row[K]>;
4
+ }>;
@@ -1,17 +1,17 @@
1
- import type { Database } from 'better-sqlite3';
2
- import { Driver } from '../Driver';
3
- import { SchemaInstructions } from '../Schema';
4
- import { Statement } from '../Statement';
5
- export declare class BetterSqlite3Driver extends Driver.Sync {
6
- db: Database;
7
- constructor(db: Database);
8
- rows<T extends object = object>([sql, params]: Statement.Compiled): Array<T>;
9
- values([sql, params]: Statement.Compiled): Array<Array<any>>;
10
- execute([sql, params]: Statement.Compiled): void;
11
- mutate([sql, params]: Statement.Compiled): {
12
- rowsAffected: number;
13
- };
14
- schemaInstructions(tableName: string): SchemaInstructions | undefined;
15
- export(): Uint8Array;
16
- }
17
- export declare function connect(db: Database): BetterSqlite3Driver;
1
+ import type { Database } from 'better-sqlite3';
2
+ import { Driver } from '../Driver';
3
+ import { SchemaInstructions } from '../Schema';
4
+ import { Statement } from '../Statement';
5
+ export declare class BetterSqlite3Driver extends Driver.Sync {
6
+ db: Database;
7
+ constructor(db: Database);
8
+ rows<T extends object = object>([sql, params]: Statement.Compiled): Array<T>;
9
+ values([sql, params]: Statement.Compiled): Array<Array<any>>;
10
+ execute([sql, params]: Statement.Compiled): void;
11
+ mutate([sql, params]: Statement.Compiled): {
12
+ rowsAffected: number;
13
+ };
14
+ schemaInstructions(tableName: string): SchemaInstructions | undefined;
15
+ export(): Uint8Array;
16
+ }
17
+ export declare function connect(db: Database): BetterSqlite3Driver;