-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from rit-sse/167-update-officer-api
add more info to officer route
- Loading branch information
Showing
2 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
import { PrismaClient } from "@prisma/client" | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const prisma = new PrismaClient() | ||
const prisma = new PrismaClient(); | ||
|
||
export async function GET() { | ||
const officer = await prisma.officer.findMany({ where: { is_active: true } }) | ||
return Response.json(officer) | ||
} | ||
const officer = await prisma.officer.findMany({ | ||
where: { is_active: true }, | ||
select: { | ||
user: { | ||
select: { | ||
name: true, | ||
email: true, | ||
}, | ||
}, | ||
position: { | ||
select: { | ||
is_primary: true, | ||
title: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
return Response.json(officer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
import { PrismaClient } from "@prisma/client" | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const prisma = new PrismaClient() | ||
const prisma = new PrismaClient(); | ||
|
||
export async function GET() { | ||
const officer = await prisma.officer.findMany() | ||
return Response.json(officer) | ||
} | ||
const officer = await prisma.officer.findMany({ | ||
select: { | ||
is_active: true, | ||
start_date: true, | ||
end_date: true, | ||
user: { | ||
select: { | ||
name: true, | ||
email: true, | ||
}, | ||
}, | ||
position: { | ||
select: { | ||
is_primary: true, | ||
title: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
return Response.json(officer); | ||
} |