rado 0.2.32 → 0.2.33
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/define/Ops.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Selection } from './Selection.js';
|
|
|
2
2
|
import { Table } from './Table.js';
|
|
3
3
|
import { Batch } from './query/Batch.js';
|
|
4
4
|
import { Delete } from './query/Delete.js';
|
|
5
|
-
import {
|
|
5
|
+
import { InsertInto } from './query/Insert.js';
|
|
6
6
|
import { Select } from './query/Select.js';
|
|
7
7
|
import { RecursiveUnion } from './query/Union.js';
|
|
8
8
|
import { Update } from './query/Update.js';
|
|
@@ -10,7 +10,7 @@ export declare function withRecursive<Row>(initialSelect: Select<Row>): Recursiv
|
|
|
10
10
|
export declare function alias<T extends Table<{}>>(table: T): Record<string, T>;
|
|
11
11
|
export declare function select<X extends Selection>(selection: X): Select<Selection.Infer<X>>;
|
|
12
12
|
export declare function from<Row>(source: Table<Row> | Select<Row>): Select<Row>;
|
|
13
|
-
export declare function update<
|
|
14
|
-
export declare function insertInto<
|
|
13
|
+
export declare function update<Definition>(table: Table<Definition>): Update<Definition>;
|
|
14
|
+
export declare function insertInto<Definition>(table: Table<Definition>): InsertInto<Definition>;
|
|
15
15
|
export declare function deleteFrom<Row>(table: Table<Row>): Delete;
|
|
16
16
|
export declare function create(...tables: Array<Table<any>>): Batch;
|
package/dist/define/Ops.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Table, createTable } from "./Table.js";
|
|
|
5
5
|
import { Target } from "./Target.js";
|
|
6
6
|
import { Batch } from "./query/Batch.js";
|
|
7
7
|
import { Delete } from "./query/Delete.js";
|
|
8
|
-
import {
|
|
8
|
+
import { InsertInto } from "./query/Insert.js";
|
|
9
9
|
import { Select } from "./query/Select.js";
|
|
10
10
|
import { RecursiveUnion } from "./query/Union.js";
|
|
11
11
|
import { Update } from "./query/Update.js";
|
|
@@ -36,10 +36,12 @@ function from(source) {
|
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
function update(table) {
|
|
39
|
-
return new Update(
|
|
39
|
+
return new Update(
|
|
40
|
+
new QueryData.Update({ table: table[Table.Data] })
|
|
41
|
+
);
|
|
40
42
|
}
|
|
41
43
|
function insertInto(table) {
|
|
42
|
-
return new
|
|
44
|
+
return new InsertInto(table[Table.Data]);
|
|
43
45
|
}
|
|
44
46
|
function deleteFrom(table) {
|
|
45
47
|
return new Delete(new QueryData.Delete({ table: table[Table.Data] }));
|
|
@@ -2,18 +2,21 @@ import { Query, QueryData } from '../Query.js';
|
|
|
2
2
|
import { Selection } from '../Selection.js';
|
|
3
3
|
import { Table, TableData } from '../Table.js';
|
|
4
4
|
import { Select } from './Select.js';
|
|
5
|
-
export declare class
|
|
6
|
-
}
|
|
7
|
-
export declare class Inserted extends Query<{
|
|
5
|
+
export declare class Insert<T = {
|
|
8
6
|
rowsAffected: number;
|
|
9
|
-
}> {
|
|
7
|
+
}> extends Query<T> {
|
|
8
|
+
[Query.Data]: QueryData.Insert;
|
|
9
|
+
constructor(query: QueryData.Insert);
|
|
10
|
+
returning<X extends Selection>(selection: X): Insert<Array<Selection.Infer<X>>>;
|
|
11
|
+
}
|
|
12
|
+
export declare class InsertOne<T> extends Query<T> {
|
|
10
13
|
[Query.Data]: QueryData.Insert;
|
|
11
14
|
constructor(query: QueryData.Insert);
|
|
12
|
-
returning<X extends Selection>(selection: X):
|
|
15
|
+
returning<X extends Selection>(selection: X): Insert<Selection.Infer<X>>;
|
|
13
16
|
}
|
|
14
|
-
export declare class
|
|
17
|
+
export declare class InsertInto<Definition> {
|
|
15
18
|
protected into: TableData;
|
|
16
19
|
constructor(into: TableData);
|
|
17
|
-
selection(query: Select<Table.Select<Definition>>):
|
|
18
|
-
values(...data: Array<Table.Insert<Definition>>):
|
|
20
|
+
selection(query: Select<Table.Select<Definition>>): Insert;
|
|
21
|
+
values(...data: Array<Table.Insert<Definition>>): Insert;
|
|
19
22
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ExprData } from "../Expr.js";
|
|
2
2
|
import { Query, QueryData } from "../Query.js";
|
|
3
|
-
class
|
|
4
|
-
}
|
|
5
|
-
class Inserted extends Query {
|
|
3
|
+
class Insert extends Query {
|
|
6
4
|
constructor(query) {
|
|
7
5
|
super(query);
|
|
8
6
|
}
|
|
9
7
|
returning(selection) {
|
|
10
|
-
return new
|
|
8
|
+
return new Insert(
|
|
11
9
|
new QueryData.Insert({
|
|
12
10
|
...this[Query.Data],
|
|
13
11
|
selection: ExprData.create(selection)
|
|
@@ -15,21 +13,35 @@ class Inserted extends Query {
|
|
|
15
13
|
);
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
|
-
class
|
|
16
|
+
class InsertOne extends Query {
|
|
17
|
+
constructor(query) {
|
|
18
|
+
super(query);
|
|
19
|
+
}
|
|
20
|
+
returning(selection) {
|
|
21
|
+
return new Insert(
|
|
22
|
+
new QueryData.Insert({
|
|
23
|
+
...this[Query.Data],
|
|
24
|
+
selection: ExprData.create(selection),
|
|
25
|
+
singleResult: true
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
class InsertInto {
|
|
19
31
|
constructor(into) {
|
|
20
32
|
this.into = into;
|
|
21
33
|
}
|
|
22
34
|
selection(query) {
|
|
23
|
-
return new
|
|
35
|
+
return new Insert(
|
|
24
36
|
new QueryData.Insert({ into: this.into, select: query[Query.Data] })
|
|
25
37
|
);
|
|
26
38
|
}
|
|
27
39
|
values(...data) {
|
|
28
|
-
return new
|
|
40
|
+
return new Insert(new QueryData.Insert({ into: this.into, data }));
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
43
|
export {
|
|
32
44
|
Insert,
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
InsertInto,
|
|
46
|
+
InsertOne
|
|
35
47
|
};
|
|
@@ -3,7 +3,7 @@ import { Query, QueryData } from '../Query.js';
|
|
|
3
3
|
import { Table, TableData } from '../Table.js';
|
|
4
4
|
import { CreateTable } from './CreateTable.js';
|
|
5
5
|
import { Delete } from './Delete.js';
|
|
6
|
-
import {
|
|
6
|
+
import { Insert, InsertOne } from './Insert.js';
|
|
7
7
|
import { Select } from './Select.js';
|
|
8
8
|
import { Update } from './Update.js';
|
|
9
9
|
export declare class TableSelect<Definition> extends Select<Table.Select<Definition>> {
|
|
@@ -12,9 +12,16 @@ export declare class TableSelect<Definition> extends Select<Table.Select<Definit
|
|
|
12
12
|
constructor(table: TableData, conditions?: Array<EV<boolean>>);
|
|
13
13
|
as(alias: string): Table<Definition>;
|
|
14
14
|
create(): CreateTable;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
insert(query: Select<Table.Insert<Definition>>): Insert;
|
|
16
|
+
insert(rows: Array<Table.Insert<Definition>>): Insert;
|
|
17
|
+
insert(row: Table.Insert<Definition>): InsertOne<Table.Select<Definition>>;
|
|
18
|
+
insertSelect(query: Select<Table.Insert<Definition>>): Insert<{
|
|
19
|
+
rowsAffected: number;
|
|
20
|
+
}>;
|
|
21
|
+
insertOne(record: Table.Insert<Definition>): InsertOne<{ [K in keyof Definition as Definition[K] extends import("../Column.js").Column<any> ? K : never]: Definition[K] extends import("../Column.js").Column<infer T> ? T : never; }>;
|
|
22
|
+
insertAll(data: Array<Table.Insert<Definition>>): Insert<{
|
|
23
|
+
rowsAffected: number;
|
|
24
|
+
}>;
|
|
18
25
|
set(data: Table.Update<Definition>): Update<Definition>;
|
|
19
26
|
delete(): Delete;
|
|
20
27
|
get(name: string): Expr<any>;
|
|
@@ -4,7 +4,7 @@ import { createTable } from "../Table.js";
|
|
|
4
4
|
import { Target } from "../Target.js";
|
|
5
5
|
import { CreateTable } from "./CreateTable.js";
|
|
6
6
|
import { Delete } from "./Delete.js";
|
|
7
|
-
import { Insert,
|
|
7
|
+
import { Insert, InsertInto, InsertOne } from "./Insert.js";
|
|
8
8
|
import { Select } from "./Select.js";
|
|
9
9
|
import { Update } from "./Update.js";
|
|
10
10
|
class TableSelect extends Select {
|
|
@@ -25,13 +25,22 @@ class TableSelect extends Select {
|
|
|
25
25
|
create() {
|
|
26
26
|
return new CreateTable(this.table);
|
|
27
27
|
}
|
|
28
|
+
insert(input) {
|
|
29
|
+
if (input instanceof Select) {
|
|
30
|
+
return this.insertSelect(input);
|
|
31
|
+
} else if (Array.isArray(input)) {
|
|
32
|
+
return this.insertAll(input);
|
|
33
|
+
} else {
|
|
34
|
+
return this.insertOne(input);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
28
37
|
insertSelect(query) {
|
|
29
|
-
return new
|
|
38
|
+
return new Insert(
|
|
30
39
|
new QueryData.Insert({ into: this.table, select: query[Query.Data] })
|
|
31
40
|
);
|
|
32
41
|
}
|
|
33
42
|
insertOne(record) {
|
|
34
|
-
return new
|
|
43
|
+
return new InsertOne(
|
|
35
44
|
new QueryData.Insert({
|
|
36
45
|
into: this.table,
|
|
37
46
|
data: [record],
|
|
@@ -41,7 +50,7 @@ class TableSelect extends Select {
|
|
|
41
50
|
);
|
|
42
51
|
}
|
|
43
52
|
insertAll(data) {
|
|
44
|
-
return new
|
|
53
|
+
return new InsertInto(this.table).values(...data);
|
|
45
54
|
}
|
|
46
55
|
set(data) {
|
|
47
56
|
return new Update(
|