chore: Add tripId field to Adventure interface and schema
This commit is contained in:
@@ -91,7 +91,6 @@ export const userPlannedTrips = pgTable("userPlannedTrips", {
|
||||
description: text("description"),
|
||||
startDate: text("startDate"),
|
||||
endDate: text("endDate"),
|
||||
adventures: json("adventures"),
|
||||
});
|
||||
|
||||
export const adventureTable = pgTable("adventures", {
|
||||
@@ -106,4 +105,5 @@ export const adventureTable = pgTable("adventures", {
|
||||
link: text("link"),
|
||||
imageUrl: text("imageUrl"),
|
||||
date: text("date"),
|
||||
tripId: integer("tripId").references(() => userPlannedTrips.id),
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ export interface Adventure {
|
||||
link?: string | undefined;
|
||||
imageUrl?: string | undefined;
|
||||
date?: string | undefined;
|
||||
tripId?: number | undefined;
|
||||
}
|
||||
|
||||
export interface Trip {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { lucia } from "$lib/server/auth";
|
||||
import { error, type RequestEvent } from "@sveltejs/kit";
|
||||
import { adventureTable } from "$lib/db/schema";
|
||||
import { db } from "$lib/db/db.server";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { and, eq, isNull } from "drizzle-orm";
|
||||
import type { Adventure } from "$lib/utils/types";
|
||||
|
||||
// Gets all the adventures that the user has visited
|
||||
@@ -21,7 +21,8 @@ export async function GET(event: RequestEvent): Promise<Response> {
|
||||
.where(
|
||||
and(
|
||||
eq(adventureTable.userId, event.locals.user.id),
|
||||
eq(adventureTable.type, "planner")
|
||||
eq(adventureTable.type, "planner"),
|
||||
isNull(adventureTable.tripId)
|
||||
)
|
||||
)
|
||||
.execute();
|
||||
|
||||
Reference in New Issue
Block a user