Skip to main content

List Groups

List all groups in a database.

Definition​

await zkdb.db(databaseName: string)
.groupList(): Promise<Result<TGroupListAllResponse[]>>;

Parameters​

  • None

Returns​

  • Promise<Result<TGroupListAllResponse>>: Returns a Result containing an array of all groups in the database with their metadata including group names, descriptions, member counts, and creation details. This provides a complete overview of the permission structure and user organization within the database.
type TGroupListAllResponse = {
groupName: string;
groupDescription: string;
createdBy: string;
createdAt: string | Date;
updatedAt: string | Date;
};

Example​

import { ZkDatabase } from 'zkdb';

const zkdb = new ZkDatabase({
apiKey: 'zkdb_536aac02a1b7.c001b6b8f...da3aa4185d8d2ad07f0ae94aT',
// This URL is for test environment
url: "https://serverless.zkdatabase.org/graphql",
});
const dbTest = zkdb.db('zkdb_test');
const groups = (await dbTest.groupList()).unwrap();
console.log('Groups:', groups);

Result:​

Groups: [
{
"groupName": "admin",
"groupDescription": "Admin group",
"createdBy": "chiro-user",
"createdAt": "2025-01-01T00:00:00.000Z",
"updatedAt": "2025-01-01T00:00:00.000Z"
},
{
"groupName": "dev",
"groupDescription": "Developer team",
"createdBy": "chiro-user",
"createdAt": "2025-09-03T00:00:00.000Z",
"updatedAt": "2025-09-03T00:00:00.000Z"
}
]