mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
scaffold create/edit beer form, scaffold beer page
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import GetAllBreweryPostsQueryResult from './types/BreweryPostQueryResult';
|
||||
import BreweryPostQueryResult from './types/BreweryPostQueryResult';
|
||||
|
||||
const prisma = DBClient.instance;
|
||||
|
||||
const getAllBreweryPosts = async () => {
|
||||
const breweryPosts: GetAllBreweryPostsQueryResult[] = await prisma.breweryPost.findMany(
|
||||
{
|
||||
select: {
|
||||
id: true,
|
||||
location: true,
|
||||
name: true,
|
||||
postedBy: { select: { firstName: true, lastName: true, id: true } },
|
||||
},
|
||||
const breweryPosts: BreweryPostQueryResult[] = await prisma.breweryPost.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
location: true,
|
||||
name: true,
|
||||
postedBy: { select: { firstName: true, lastName: true, id: true } },
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
return breweryPosts;
|
||||
};
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import GetAllBreweryPostsQueryResult from './types/BreweryPostQueryResult';
|
||||
import BreweryPostQueryResult from './types/BreweryPostQueryResult';
|
||||
|
||||
const prisma = DBClient.instance;
|
||||
|
||||
const getBreweryPostById = async (id: string) => {
|
||||
const breweryPost: GetAllBreweryPostsQueryResult | null =
|
||||
await prisma.breweryPost.findFirst({
|
||||
select: {
|
||||
id: true,
|
||||
location: true,
|
||||
name: true,
|
||||
postedBy: {
|
||||
select: {
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
id: true,
|
||||
},
|
||||
const breweryPost: BreweryPostQueryResult | null = await prisma.breweryPost.findFirst({
|
||||
select: {
|
||||
id: true,
|
||||
location: true,
|
||||
name: true,
|
||||
postedBy: {
|
||||
select: {
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
},
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
return breweryPost;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default interface GetAllBreweryPostsQueryResult {
|
||||
export default interface BreweryPostQueryResult {
|
||||
id: string;
|
||||
location: string;
|
||||
name: string;
|
||||
|
||||
Reference in New Issue
Block a user