Browse Source

feat(api): add option to pass aggregate field name

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3962/head
Pranav C 2 years ago
parent
commit
457b0b1128
  1. 1
      packages/nocodb/src/lib/meta/NcMetaIO.ts
  2. 3
      packages/nocodb/src/lib/meta/NcMetaIOImpl.ts

1
packages/nocodb/src/lib/meta/NcMetaIO.ts

@ -169,6 +169,7 @@ export default abstract class NcMetaIO {
args?: {
condition?: { [key: string]: any };
xcCondition?: XcCondition;
aggField?: string;
}
): Promise<number>;

3
packages/nocodb/src/lib/meta/NcMetaIOImpl.ts

@ -374,6 +374,7 @@ export default class NcMetaIOImpl extends NcMetaIO {
args?: {
condition?: { [p: string]: any };
xcCondition?;
aggField?: string;
}
): Promise<number> {
const query = this.knexConnection(target);
@ -393,7 +394,7 @@ export default class NcMetaIOImpl extends NcMetaIO {
(query as any).condition(args.xcCondition);
}
query.count('id', { as: 'count' }).first();
query.count(args?.aggField || 'id', { as: 'count' }).first();
return +(await query)?.['count'] || 0;
}

Loading…
Cancel
Save