Add and delete migration files
This commit is contained in:
@@ -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(),
|
||||
});
|
||||
|
||||
19
src/routes/worldtravel/+page.server.ts
Normal file
19
src/routes/worldtravel/+page.server.ts
Normal 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,
|
||||
};
|
||||
};
|
||||
20
src/routes/worldtravel/+page.svelte
Normal file
20
src/routes/worldtravel/+page.svelte
Normal 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}
|
||||
Reference in New Issue
Block a user