mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Create location table for brewery post locations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
const prisma = DBClient.instance;
|
||||
@@ -14,11 +15,15 @@ const getAllBreweryPosts = async (pageNum?: number, pageSize?: number) => {
|
||||
take,
|
||||
select: {
|
||||
id: true,
|
||||
coordinates: true,
|
||||
address: true,
|
||||
city: true,
|
||||
stateOrProvince: true,
|
||||
country: true,
|
||||
location: {
|
||||
select: {
|
||||
city: true,
|
||||
address: true,
|
||||
coordinates: true,
|
||||
country: true,
|
||||
stateOrProvince: true,
|
||||
},
|
||||
},
|
||||
description: true,
|
||||
name: true,
|
||||
postedBy: { select: { username: true, id: true } },
|
||||
|
||||
@@ -9,11 +9,15 @@ const getBreweryPostById = async (id: string) => {
|
||||
await prisma.breweryPost.findFirst({
|
||||
select: {
|
||||
id: true,
|
||||
coordinates: true,
|
||||
address: true,
|
||||
city: true,
|
||||
stateOrProvince: true,
|
||||
country: true,
|
||||
location: {
|
||||
select: {
|
||||
city: true,
|
||||
address: true,
|
||||
coordinates: true,
|
||||
country: true,
|
||||
stateOrProvince: true,
|
||||
},
|
||||
},
|
||||
description: true,
|
||||
name: true,
|
||||
breweryImages: { select: { path: true, caption: true, id: true, alt: true } },
|
||||
|
||||
@@ -4,11 +4,13 @@ const BreweryPostQueryResult = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
address: z.string(),
|
||||
city: z.string(),
|
||||
stateOrProvince: z.string().or(z.null()),
|
||||
coordinates: z.array(z.number()),
|
||||
country: z.string().or(z.null()),
|
||||
location: z.object({
|
||||
city: z.string(),
|
||||
address: z.string(),
|
||||
coordinates: z.array(z.number()),
|
||||
country: z.string().nullable(),
|
||||
stateOrProvince: z.string().nullable(),
|
||||
}),
|
||||
postedBy: z.object({ id: z.string(), username: z.string() }),
|
||||
breweryImages: z.array(
|
||||
z.object({ path: z.string(), caption: z.string(), id: z.string(), alt: z.string() }),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import DBClient from '../../prisma/DBClient';
|
||||
|
||||
const findUserByEmail = async (email: string) =>
|
||||
DBClient.instance.user.findFirst({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import DBClient from '../../prisma/DBClient';
|
||||
|
||||
const findUserByUsername = async (username: string) =>
|
||||
DBClient.instance.user.findFirst({
|
||||
|
||||
Reference in New Issue
Block a user