Browse Source

feat(api): add project count in api

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
5587d5857d
  1. 19
      packages/nocodb/src/lib/models/User.ts

19
packages/nocodb/src/lib/models/User.ts

@ -134,10 +134,21 @@ export default class User implements UserType {
return false;
}
static async count(ncMeta = Noco.ncMeta) {
return (
await ncMeta.knex(MetaTable.USERS).count('id', { as: 'count' }).first()
)?.count;
public static async count(
{
query = '',
}: {
query?: string;
} = {},
ncMeta = Noco.ncMeta
): Promise<number> {
const qb = ncMeta.knex(MetaTable.USERS);
if (query) {
qb.where('email', 'like', `%${query.toLowerCase?.()}%`);
}
return (await qb.count('id', { as: 'count' }).first()).count;
}
static async get(userId, ncMeta = Noco.ncMeta) {

Loading…
Cancel
Save