feat: conditional filtering & aggregation support & data ordering support (#2107)

* feat: wip

* feat: add filter on findOne

* fix: tests & small bug

* feat: add test and support aggregation

* feat: add order by support

* fix: fix comments

* fix: tests
This commit is contained in:
Jérémy M
2023-10-19 15:24:36 +02:00
committed by GitHub
parent 2b8a81a05c
commit 3e83cb6846
23 changed files with 555 additions and 156 deletions

View File

@ -58,18 +58,30 @@ export class PGGraphQLQueryRunner {
return parseResult(result);
}
async findMany(): Promise<any[]> {
const query = this.queryBuilder.findMany();
async findMany(args: {
first?: number;
last?: number;
before?: string;
after?: string;
filter?: any;
orderBy?: any;
}): Promise<any[]> {
const query = this.queryBuilder.findMany(args);
const result = await this.execute(query, this.options.workspaceId);
return this.parseResult(result, '');
}
async findOne(args: { id: string }): Promise<any> {
async findOne(args: { filter?: any }): Promise<any> {
if (!args.filter || Object.keys(args.filter).length === 0) {
throw new BadRequestException('Missing filter argument');
}
const query = this.queryBuilder.findOne(args);
const result = await this.execute(query, this.options.workspaceId);
const parsedResult = this.parseResult(result, '');
return this.parseResult(result, '');
return parsedResult?.edges?.[0]?.node;
}
async createMany(args: { data: any[] }): Promise<any[]> {