Skip to main content

List Groups

List all groups in a database.

Definition

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

Parameters

  • None

Returns

  • Promise<TGroupListAllResponse[]>: Returns 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 = await ZkDatabase.connect({
userName: "chiro-user",
privateKey: "EKFTciRxyxshZjimay9sktsn7v5PvmC5zPq7q4JnitHUytxUVnFP",
environment: "node",
// This URL is for test environment
url: "https://api.zkdatabase.org/graphql",
});

await zkdb.auth.signIn();

const dbTest = zkdb.db('zkdb_test');
const groups = await dbTest.groupList();
console.log('Groups:', groups);

await zkdb.auth.signOut();

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"
}
]