UNPKG

3.37 kBTypeScriptView Raw
1import { QueryBuilder } from "./QueryBuilder";
2import { ObjectLiteral } from "../common/ObjectLiteral";
3import { ObjectType } from "../common/ObjectType";
4import { QueryDeepPartialEntity } from "./QueryPartialEntity";
5import { InsertResult } from "./result/InsertResult";
6import { ColumnMetadata } from "../metadata/ColumnMetadata";
7import { EntitySchema } from "../";
8/**
9 * Allows to build complex sql queries in a fashion way and execute those queries.
10 */
11export declare class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
12 /**
13 * Gets generated sql query without parameters being replaced.
14 */
15 getQuery(): string;
16 /**
17 * Executes sql generated by query builder and returns raw database results.
18 */
19 execute(): Promise<InsertResult>;
20 /**
21 * Specifies INTO which entity's table insertion will be executed.
22 */
23 into<T>(entityTarget: ObjectType<T> | EntitySchema<T> | string, columns?: string[]): InsertQueryBuilder<T>;
24 /**
25 * Values needs to be inserted into table.
26 */
27 values(values: QueryDeepPartialEntity<Entity> | QueryDeepPartialEntity<Entity>[]): this;
28 /**
29 * Optional returning/output clause.
30 * This will return given column values.
31 */
32 output(columns: string[]): this;
33 /**
34 * Optional returning/output clause.
35 * Returning is a SQL string containing returning statement.
36 */
37 output(output: string): this;
38 /**
39 * Optional returning/output clause.
40 */
41 output(output: string | string[]): this;
42 /**
43 * Optional returning/output clause.
44 * This will return given column values.
45 */
46 returning(columns: string[]): this;
47 /**
48 * Optional returning/output clause.
49 * Returning is a SQL string containing returning statement.
50 */
51 returning(returning: string): this;
52 /**
53 * Optional returning/output clause.
54 */
55 returning(returning: string | string[]): this;
56 /**
57 * Indicates if entity must be updated after insertion operations.
58 * This may produce extra query or use RETURNING / OUTPUT statement (depend on database).
59 * Enabled by default.
60 */
61 updateEntity(enabled: boolean): this;
62 /**
63 * Adds additional ON CONFLICT statement supported in postgres.
64 */
65 onConflict(statement: string): this;
66 /**
67 * Adds additional ignore statement supported in databases.
68 */
69 orIgnore(statement?: string | boolean): this;
70 /**
71 * Adds additional update statement supported in databases.
72 */
73 orUpdate(statement?: {
74 columns?: string[];
75 overwrite?: string[];
76 conflict_target?: string | string[];
77 }): this;
78 /**
79 * Creates INSERT express used to perform insert query.
80 */
81 protected createInsertExpression(): string;
82 /**
83 * Gets list of columns where values must be inserted to.
84 */
85 protected getInsertedColumns(): ColumnMetadata[];
86 /**
87 * Creates a columns string where values must be inserted to for INSERT INTO expression.
88 */
89 protected createColumnNamesExpression(): string;
90 /**
91 * Creates list of values needs to be inserted in the VALUES expression.
92 */
93 protected createValuesExpression(): string;
94 /**
95 * Gets array of values need to be inserted into the target table.
96 */
97 protected getValueSets(): ObjectLiteral[];
98}