1 | import * as tslib_1 from "tslib";
|
2 |
|
3 |
|
4 | import "reflect-metadata";
|
5 | import { ConnectionManager } from "./connection/ConnectionManager";
|
6 | import { MetadataArgsStorage } from "./metadata-args/MetadataArgsStorage";
|
7 | import { getFromContainer } from "./container";
|
8 | import { PlatformTools } from "./platform/PlatformTools";
|
9 | import { ConnectionOptionsReader } from "./connection/ConnectionOptionsReader";
|
10 | import { PromiseUtils } from "./util/PromiseUtils";
|
11 |
|
12 |
|
13 |
|
14 | export * from "./container";
|
15 | export * from "./error/QueryFailedError";
|
16 | export * from "./decorator/columns/Column";
|
17 | export * from "./decorator/columns/CreateDateColumn";
|
18 | export * from "./decorator/columns/PrimaryGeneratedColumn";
|
19 | export * from "./decorator/columns/PrimaryColumn";
|
20 | export * from "./decorator/columns/UpdateDateColumn";
|
21 | export * from "./decorator/columns/VersionColumn";
|
22 | export * from "./decorator/columns/ViewColumn";
|
23 | export * from "./decorator/columns/ObjectIdColumn";
|
24 | export * from "./decorator/listeners/AfterInsert";
|
25 | export * from "./decorator/listeners/AfterLoad";
|
26 | export * from "./decorator/listeners/AfterRemove";
|
27 | export * from "./decorator/listeners/AfterUpdate";
|
28 | export * from "./decorator/listeners/BeforeInsert";
|
29 | export * from "./decorator/listeners/BeforeRemove";
|
30 | export * from "./decorator/listeners/BeforeUpdate";
|
31 | export * from "./decorator/listeners/EventSubscriber";
|
32 | export * from "./decorator/relations/JoinColumn";
|
33 | export * from "./decorator/relations/JoinTable";
|
34 | export * from "./decorator/relations/ManyToMany";
|
35 | export * from "./decorator/relations/ManyToOne";
|
36 | export * from "./decorator/relations/OneToMany";
|
37 | export * from "./decorator/relations/OneToOne";
|
38 | export * from "./decorator/relations/RelationCount";
|
39 | export * from "./decorator/relations/RelationId";
|
40 | export * from "./decorator/entity/Entity";
|
41 | export * from "./decorator/entity/ChildEntity";
|
42 | export * from "./decorator/entity/TableInheritance";
|
43 | export * from "./decorator/entity-view/ViewEntity";
|
44 | export * from "./decorator/transaction/Transaction";
|
45 | export * from "./decorator/transaction/TransactionManager";
|
46 | export * from "./decorator/transaction/TransactionRepository";
|
47 | export * from "./decorator/tree/TreeLevelColumn";
|
48 | export * from "./decorator/tree/TreeParent";
|
49 | export * from "./decorator/tree/TreeChildren";
|
50 | export * from "./decorator/tree/Tree";
|
51 | export * from "./decorator/Index";
|
52 | export * from "./decorator/Unique";
|
53 | export * from "./decorator/Check";
|
54 | export * from "./decorator/Exclusion";
|
55 | export * from "./decorator/Generated";
|
56 | export * from "./decorator/EntityRepository";
|
57 | export * from "./find-options/operator/Any";
|
58 | export * from "./find-options/operator/Between";
|
59 | export * from "./find-options/operator/Equal";
|
60 | export * from "./find-options/operator/In";
|
61 | export * from "./find-options/operator/IsNull";
|
62 | export * from "./find-options/operator/LessThan";
|
63 | export * from "./find-options/operator/LessThanOrEqual";
|
64 | export * from "./find-options/operator/Like";
|
65 | export * from "./find-options/operator/MoreThan";
|
66 | export * from "./find-options/operator/MoreThanOrEqual";
|
67 | export * from "./find-options/operator/Not";
|
68 | export * from "./find-options/operator/Raw";
|
69 | export * from "./find-options/FindOperator";
|
70 | export * from "./logger/AdvancedConsoleLogger";
|
71 | export * from "./logger/SimpleConsoleLogger";
|
72 | export * from "./logger/FileLogger";
|
73 | export * from "./metadata/EntityMetadata";
|
74 | export * from "./entity-manager/EntityManager";
|
75 | export * from "./repository/AbstractRepository";
|
76 | export * from "./repository/Repository";
|
77 | export * from "./repository/BaseEntity";
|
78 | export * from "./repository/TreeRepository";
|
79 | export * from "./repository/MongoRepository";
|
80 | export * from "./schema-builder/table/TableColumn";
|
81 | export * from "./schema-builder/table/TableForeignKey";
|
82 | export * from "./schema-builder/table/TableIndex";
|
83 | export * from "./schema-builder/table/Table";
|
84 | export * from "./driver/mongodb/typings";
|
85 | export * from "./driver/sqlserver/MssqlParameter";
|
86 | export { ConnectionOptionsReader } from "./connection/ConnectionOptionsReader";
|
87 | export { Connection } from "./connection/Connection";
|
88 | export { ConnectionManager } from "./connection/ConnectionManager";
|
89 | export { QueryBuilder } from "./query-builder/QueryBuilder";
|
90 | export { SelectQueryBuilder } from "./query-builder/SelectQueryBuilder";
|
91 | export { DeleteQueryBuilder } from "./query-builder/DeleteQueryBuilder";
|
92 | export { InsertQueryBuilder } from "./query-builder/InsertQueryBuilder";
|
93 | export { UpdateQueryBuilder } from "./query-builder/UpdateQueryBuilder";
|
94 | export { RelationQueryBuilder } from "./query-builder/RelationQueryBuilder";
|
95 | export { Brackets } from "./query-builder/Brackets";
|
96 | export { InsertResult } from "./query-builder/result/InsertResult";
|
97 | export { UpdateResult } from "./query-builder/result/UpdateResult";
|
98 | export { DeleteResult } from "./query-builder/result/DeleteResult";
|
99 | export { EntityManager } from "./entity-manager/EntityManager";
|
100 | export { MongoEntityManager } from "./entity-manager/MongoEntityManager";
|
101 | export { DefaultNamingStrategy } from "./naming-strategy/DefaultNamingStrategy";
|
102 | export { Repository } from "./repository/Repository";
|
103 | export { TreeRepository } from "./repository/TreeRepository";
|
104 | export { MongoRepository } from "./repository/MongoRepository";
|
105 | export { BaseEntity } from "./repository/BaseEntity";
|
106 | export { EntitySchema } from "./entity-schema/EntitySchema";
|
107 | export { PromiseUtils } from "./util/PromiseUtils";
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | export function getMetadataArgsStorage() {
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 | var globalScope = PlatformTools.getGlobalVariable();
|
127 | if (!globalScope.typeormMetadataArgsStorage)
|
128 | globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage();
|
129 | return globalScope.typeormMetadataArgsStorage;
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 | export function getConnectionOptions(connectionName) {
|
135 | if (connectionName === void 0) { connectionName = "default"; }
|
136 | return tslib_1.__awaiter(this, void 0, void 0, function () {
|
137 | return tslib_1.__generator(this, function (_a) {
|
138 | return [2 , new ConnectionOptionsReader().get(connectionName)];
|
139 | });
|
140 | });
|
141 | }
|
142 |
|
143 |
|
144 |
|
145 | export function getConnectionManager() {
|
146 | return getFromContainer(ConnectionManager);
|
147 | }
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | export function createConnection(optionsOrName) {
|
156 | return tslib_1.__awaiter(this, void 0, void 0, function () {
|
157 | var connectionName, options, _a;
|
158 | return tslib_1.__generator(this, function (_b) {
|
159 | switch (_b.label) {
|
160 | case 0:
|
161 | connectionName = typeof optionsOrName === "string" ? optionsOrName : "default";
|
162 | if (!(optionsOrName instanceof Object)) return [3 , 1];
|
163 | _a = optionsOrName;
|
164 | return [3 , 3];
|
165 | case 1: return [4 , getConnectionOptions(connectionName)];
|
166 | case 2:
|
167 | _a = _b.sent();
|
168 | _b.label = 3;
|
169 | case 3:
|
170 | options = _a;
|
171 | return [2 , getConnectionManager().create(options).connect()];
|
172 | }
|
173 | });
|
174 | });
|
175 | }
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 | export function createConnections(options) {
|
184 | return tslib_1.__awaiter(this, void 0, void 0, function () {
|
185 | var connections;
|
186 | return tslib_1.__generator(this, function (_a) {
|
187 | switch (_a.label) {
|
188 | case 0:
|
189 | if (!!options) return [3 , 2];
|
190 | return [4 , new ConnectionOptionsReader().all()];
|
191 | case 1:
|
192 | options = _a.sent();
|
193 | _a.label = 2;
|
194 | case 2:
|
195 | connections = options.map(function (options) { return getConnectionManager().create(options); });
|
196 | return [2 , PromiseUtils.runInSequence(connections, function (connection) { return connection.connect(); })];
|
197 | }
|
198 | });
|
199 | });
|
200 | }
|
201 |
|
202 |
|
203 |
|
204 |
|
205 | export function getConnection(connectionName) {
|
206 | if (connectionName === void 0) { connectionName = "default"; }
|
207 | return getConnectionManager().get(connectionName);
|
208 | }
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | export function getManager(connectionName) {
|
214 | if (connectionName === void 0) { connectionName = "default"; }
|
215 | return getConnectionManager().get(connectionName).manager;
|
216 | }
|
217 |
|
218 |
|
219 |
|
220 |
|
221 | export function getMongoManager(connectionName) {
|
222 | if (connectionName === void 0) { connectionName = "default"; }
|
223 | return getConnectionManager().get(connectionName).manager;
|
224 | }
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 | export function getSqljsManager(connectionName) {
|
231 | if (connectionName === void 0) { connectionName = "default"; }
|
232 | return getConnectionManager().get(connectionName).manager;
|
233 | }
|
234 |
|
235 |
|
236 |
|
237 | export function getRepository(entityClass, connectionName) {
|
238 | if (connectionName === void 0) { connectionName = "default"; }
|
239 | return getConnectionManager().get(connectionName).getRepository(entityClass);
|
240 | }
|
241 |
|
242 |
|
243 |
|
244 | export function getTreeRepository(entityClass, connectionName) {
|
245 | if (connectionName === void 0) { connectionName = "default"; }
|
246 | return getConnectionManager().get(connectionName).getTreeRepository(entityClass);
|
247 | }
|
248 |
|
249 |
|
250 |
|
251 | export function getCustomRepository(customRepository, connectionName) {
|
252 | if (connectionName === void 0) { connectionName = "default"; }
|
253 | return getConnectionManager().get(connectionName).getCustomRepository(customRepository);
|
254 | }
|
255 |
|
256 |
|
257 |
|
258 | export function getMongoRepository(entityClass, connectionName) {
|
259 | if (connectionName === void 0) { connectionName = "default"; }
|
260 | return getConnectionManager().get(connectionName).getMongoRepository(entityClass);
|
261 | }
|
262 |
|
263 |
|
264 |
|
265 | export function createQueryBuilder(entityClass, alias, connectionName) {
|
266 | if (connectionName === void 0) { connectionName = "default"; }
|
267 | if (entityClass) {
|
268 | return getRepository(entityClass, connectionName).createQueryBuilder(alias);
|
269 | }
|
270 | return getConnection(connectionName).createQueryBuilder();
|
271 | }
|
272 |
|
273 |
|