MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / adminGetUsers

Function adminGetUsers

apps/webapp/app/models/admin.server.ts:6–99  ·  view source on GitHub ↗
(userId: string, { page, search }: SearchParams)

Source from the content-addressed store, hash-verified

4const pageSize = 20;
5
6export async function adminGetUsers(userId: string, { page, search }: SearchParams) {
7 page = page || 1;
8
9 search = search ? decodeURIComponent(search) : undefined;
10
11 const user = await prisma.user.findUnique({
12 where: {
13 id: userId,
14 },
15 });
16
17 if (user?.admin !== true) {
18 throw new Error("Unauthorized");
19 }
20
21 const users = await prisma.user.findMany({
22 select: {
23 id: true,
24 name: true,
25 email: true,
26 admin: true,
27 createdAt: true,
28 displayName: true,
29 orgMemberships: {
30 select: {
31 organization: {
32 select: {
33 title: true,
34 slug: true,
35 },
36 },
37 },
38 },
39 },
40 where: search
41 ? {
42 OR: [
43 {
44 name: {
45 contains: search,
46 mode: "insensitive",
47 },
48 },
49 {
50 email: {
51 contains: search,
52 mode: "insensitive",
53 },
54 },
55 {
56 orgMemberships: {
57 some: {
58 organization: {
59 title: {
60 contains: search,
61 mode: "insensitive",
62 },
63 },

Callers 1

loaderFunction · 0.90

Calls 1

countMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…