@mikro-orm/knex 7.0.0-dev.2 → 7.0.0-dev.3
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/package.json +2 -2
- package/query/QueryBuilder.d.ts +0 -7
- package/query/QueryBuilder.js +0 -20
- package/schema/SqlSchemaGenerator.js +2 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.3",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"@mikro-orm/core": "^6.4.5"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
60
|
+
"@mikro-orm/core": "7.0.0-dev.3"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -256,10 +256,6 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
256
256
|
* Executes the query, returning both array of results and total count query (without offset and limit).
|
|
257
257
|
*/
|
|
258
258
|
getResultAndCount(): Promise<[Entity[], number]>;
|
|
259
|
-
/**
|
|
260
|
-
* Provides promise-like interface so we can await the QB instance.
|
|
261
|
-
*/
|
|
262
|
-
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<Loaded<Entity, Hint>[] | number | QueryResult<Entity>>;
|
|
263
259
|
/**
|
|
264
260
|
* Returns native query builder instance with sub-query aliased with given alias.
|
|
265
261
|
* You can provide `EntityName.propName` as alias, then the field name will be used based on the metadata
|
|
@@ -303,14 +299,12 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
303
299
|
export interface RunQueryBuilder<Entity extends object> extends Omit<QueryBuilder<Entity, any, any>, 'getResult' | 'getSingleResult' | 'getResultList' | 'where'> {
|
|
304
300
|
where(cond: QBFilterQuery<Entity> | string, params?: keyof typeof GroupOperator | any[], operator?: keyof typeof GroupOperator): this;
|
|
305
301
|
execute<Result = QueryResult<Entity>>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<Result>;
|
|
306
|
-
then<TResult1 = QueryResult<Entity>, TResult2 = never>(onfulfilled?: ((value: QueryResult<Entity>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<QueryResult<Entity>>;
|
|
307
302
|
}
|
|
308
303
|
export interface SelectQueryBuilder<Entity extends object = AnyEntity, RootAlias extends string = never, Hint extends string = never, Context extends object = never> extends QueryBuilder<Entity, RootAlias, Hint, Context> {
|
|
309
304
|
execute<Result = Entity[]>(method?: 'all' | 'get' | 'run', mapResults?: boolean): Promise<Result>;
|
|
310
305
|
execute<Result = Entity[]>(method: 'all', mapResults?: boolean): Promise<Result>;
|
|
311
306
|
execute<Result = Entity>(method: 'get', mapResults?: boolean): Promise<Result>;
|
|
312
307
|
execute<Result = QueryResult<Entity>>(method: 'run', mapResults?: boolean): Promise<Result>;
|
|
313
|
-
then<TResult1 = Entity[], TResult2 = never>(onfulfilled?: ((value: Loaded<Entity, Hint>[]) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<Loaded<Entity, Hint>[]>;
|
|
314
308
|
}
|
|
315
309
|
export interface CountQueryBuilder<Entity extends object> extends QueryBuilder<Entity, any, any> {
|
|
316
310
|
execute<Result = {
|
|
@@ -325,7 +319,6 @@ export interface CountQueryBuilder<Entity extends object> extends QueryBuilder<E
|
|
|
325
319
|
execute<Result = QueryResult<{
|
|
326
320
|
count: number;
|
|
327
321
|
}>>(method: 'run', mapResults?: boolean): Promise<Result>;
|
|
328
|
-
then<TResult1 = number, TResult2 = never>(onfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<number>;
|
|
329
322
|
}
|
|
330
323
|
export interface InsertQueryBuilder<T extends object> extends RunQueryBuilder<T> {
|
|
331
324
|
}
|
package/query/QueryBuilder.js
CHANGED
|
@@ -753,26 +753,6 @@ export class QueryBuilder {
|
|
|
753
753
|
await this.clone().getCount(),
|
|
754
754
|
];
|
|
755
755
|
}
|
|
756
|
-
/**
|
|
757
|
-
* Provides promise-like interface so we can await the QB instance.
|
|
758
|
-
*/
|
|
759
|
-
then(onfulfilled, onrejected) {
|
|
760
|
-
let type = this.type;
|
|
761
|
-
if (this.flags.has(QueryFlag.UPDATE_SUB_QUERY) || this.flags.has(QueryFlag.DELETE_SUB_QUERY)) {
|
|
762
|
-
type = QueryType.UPDATE;
|
|
763
|
-
}
|
|
764
|
-
switch (type) {
|
|
765
|
-
case QueryType.INSERT:
|
|
766
|
-
case QueryType.UPDATE:
|
|
767
|
-
case QueryType.DELETE:
|
|
768
|
-
case QueryType.UPSERT:
|
|
769
|
-
case QueryType.TRUNCATE:
|
|
770
|
-
return this.execute('run').then(onfulfilled, onrejected);
|
|
771
|
-
case QueryType.COUNT:
|
|
772
|
-
return this.getCount().then(onfulfilled, onrejected);
|
|
773
|
-
case QueryType.SELECT: return this.getResultList().then(onfulfilled, onrejected);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
756
|
/**
|
|
777
757
|
* Returns native query builder instance with sub-query aliased with given alias.
|
|
778
758
|
* You can provide `EntityName.propName` as alias, then the field name will be used based on the metadata
|
|
@@ -106,21 +106,10 @@ export class SqlSchemaGenerator extends AbstractSchemaGenerator {
|
|
|
106
106
|
for (const meta of this.getOrderedMetadata(options?.schema).reverse()) {
|
|
107
107
|
await this.driver.createQueryBuilder(meta.className, this.em?.getTransactionContext(), 'write', false)
|
|
108
108
|
.withSchema(options?.schema)
|
|
109
|
-
.truncate()
|
|
109
|
+
.truncate()
|
|
110
|
+
.execute();
|
|
110
111
|
}
|
|
111
112
|
await this.execute(this.helper.enableForeignKeysSQL());
|
|
112
|
-
// const parts: string[] = [this.helper.disableForeignKeysSQL()];
|
|
113
|
-
//
|
|
114
|
-
// for (const meta of this.getOrderedMetadata(options?.schema).reverse()) {
|
|
115
|
-
// const query = this.driver.createQueryBuilder(meta.className, this.em?.getTransactionContext(), 'write', false)
|
|
116
|
-
// .withSchema(options?.schema)
|
|
117
|
-
// .truncate()
|
|
118
|
-
// .getFormattedQuery();
|
|
119
|
-
// parts.push(query);
|
|
120
|
-
// }
|
|
121
|
-
//
|
|
122
|
-
// parts.push(this.helper.enableForeignKeysSQL());
|
|
123
|
-
// await this.execute(parts.join(';\n'));
|
|
124
113
|
this.clearIdentityMap();
|
|
125
114
|
}
|
|
126
115
|
async getDropSchemaSQL(options = {}) {
|