Create location table for brewery post locations

This commit is contained in:
Aaron William Po
2023-04-26 08:37:59 -04:00
parent 4aeafc0de8
commit c19cddceb7
17 changed files with 209 additions and 55 deletions

View File

@@ -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 } },

View File

@@ -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 } },

View File

@@ -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() }),

View File

@@ -1,4 +1,4 @@
import DBClient from '@/prisma/DBClient';
import DBClient from '../../prisma/DBClient';
const findUserByEmail = async (email: string) =>
DBClient.instance.user.findFirst({

View File

@@ -1,4 +1,4 @@
import DBClient from '@/prisma/DBClient';
import DBClient from '../../prisma/DBClient';
const findUserByUsername = async (username: string) =>
DBClient.instance.user.findFirst({