Add and delete migration files

This commit is contained in:
Sean Morley
2024-04-11 23:58:09 +00:00
parent a17c482522
commit a03fc5fb4e
38 changed files with 1663 additions and 945 deletions

View File

@@ -5,6 +5,8 @@ import {
json,
serial,
varchar,
foreignKey,
integer,
} from "drizzle-orm/pg-core";
export const featuredAdventures = pgTable("featuredAdventures", {
@@ -51,3 +53,10 @@ export const userVisitedAdventures = pgTable("userVisitedAdventures", {
location: text("location"),
visitedDate: text("visited_date"),
});
export const worldTravelCountries = pgTable("worldTravelCountries", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
country_code: text("country_code").notNull(),
continent: text("continent").notNull(),
});

View File

@@ -0,0 +1,19 @@
import { redirect } from "@sveltejs/kit";
import type { PageServerLoad } from "./$types";
import type { Adventure } from "$lib/utils/types";
import { db } from "$lib/db/db.server";
import { worldTravelCountries } from "$lib/db/schema";
export const load: PageServerLoad = async (event) => {
if (!event.locals.user) {
return redirect(302, "/login");
}
let response = await db
.select()
.from(worldTravelCountries)
// let array = result.adventures as Adventure[];
return {
response,
};
};

View File

@@ -0,0 +1,20 @@
<script lang="ts">
import { goto } from "$app/navigation";
import AdventureCard from "$lib/components/AdventureCard.svelte";
export let data: any;
console.log(data.response);
async function nav(loc: string) {
goto(`/worldtravel/${loc}`);
}
</script>
<h1>Country List</h1>
{#each data.response as item}
<button class="btn btn-primary" on:click={() => nav(item.country_code)}
>{item.name}</button
>
<!-- <p>Name: {item.name}, Continent: {item.continent}</p> -->
{/each}