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:
@ -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[]> {
|
||||
|
||||
Reference in New Issue
Block a user