listOrganizations params - docs are no help

Hi, on the server-side I'd like to grab a list of the organizations in the system. The docs don't really say what you can pass in, TS is one thing but is there a reason the docs are either light or non-existant?
2 Replies
je823
je823OP2w ago
Would I be better off just ignoring the better auth APIs if I want to list or interact with data and query the DB directly?
stepman
stepman2w ago
I had the same issue, and as far as I could tell the existing functionality was restricted to the current user's orgs only. So I built my own "Org Admin" plugin:
export const organizationAdminPlugin = () => {
return {
id: "org-admin",
endpoints: {
listAllOrganizations: createAuthEndpoint(
"/organization/admin/listall",
{
method: "GET",
},
async (ctx) => {
const orgs = ctx.context.adapter.findMany<Organization>({
model: "organization",
});
return ctx.json(orgs);
},
),
/* ... */
export const organizationAdminPlugin = () => {
return {
id: "org-admin",
endpoints: {
listAllOrganizations: createAuthEndpoint(
"/organization/admin/listall",
{
method: "GET",
},
async (ctx) => {
const orgs = ctx.context.adapter.findMany<Organization>({
model: "organization",
});
return ctx.json(orgs);
},
),
/* ... */

Did you find this page helpful?