@mikro-orm/knex 6.3.3-dev.6 → 6.3.3-dev.8
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 +4 -0
- package/query/QueryBuilder.js +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.3.3-dev.
|
|
3
|
+
"version": "6.3.3-dev.8",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@mikro-orm/core": "^6.3.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.3.3-dev.
|
|
69
|
+
"@mikro-orm/core": "6.3.3-dev.8",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -140,6 +140,10 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
140
140
|
innerJoinAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: Field | [field: Field, qb: Knex.QueryBuilder | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
|
|
141
141
|
innerJoinLateralAndSelect<Field extends QBField<Entity, RootAlias, Context>, Alias extends string>(field: [field: Field, qb: Knex.QueryBuilder | QueryBuilder<any>], alias: Alias, cond?: QBFilterQuery, fields?: string[], schema?: string): SelectQueryBuilder<Entity, RootAlias, ModifyHint<RootAlias, Context, Hint, Field, true> & {}, ModifyContext<Entity, Context, Field, Alias, true>>;
|
|
142
142
|
protected getFieldsForJoinedLoad(prop: EntityProperty<Entity>, alias: string, explicitFields?: string[]): Field<Entity>[];
|
|
143
|
+
/**
|
|
144
|
+
* Apply filters to the QB where condition.
|
|
145
|
+
*/
|
|
146
|
+
applyFilters(filterOptions?: Dictionary<boolean | Dictionary> | string[] | boolean): Promise<this>;
|
|
143
147
|
withSubQuery(subQuery: Knex.QueryBuilder, alias: string): this;
|
|
144
148
|
where(cond: QBFilterQuery<Entity>, operator?: keyof typeof GroupOperator): this;
|
|
145
149
|
where(cond: string, params?: any[], operator?: keyof typeof GroupOperator): this;
|
package/query/QueryBuilder.js
CHANGED
|
@@ -253,6 +253,18 @@ class QueryBuilder {
|
|
|
253
253
|
.forEach(prop => fields.push(...this.driver.mapPropToFieldNames(this, prop, alias)));
|
|
254
254
|
return fields;
|
|
255
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Apply filters to the QB where condition.
|
|
258
|
+
*/
|
|
259
|
+
async applyFilters(filterOptions = {}) {
|
|
260
|
+
/* istanbul ignore next */
|
|
261
|
+
if (!this.em) {
|
|
262
|
+
throw new Error('Cannot apply filters, this QueryBuilder is not attached to an EntityManager');
|
|
263
|
+
}
|
|
264
|
+
const cond = await this.em.applyFilters(this.mainAlias.entityName, {}, filterOptions, 'read');
|
|
265
|
+
this.andWhere(cond);
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
256
268
|
withSubQuery(subQuery, alias) {
|
|
257
269
|
this.ensureNotFinalized();
|
|
258
270
|
this.subQueries[alias] = subQuery.toString();
|