Skip to content

Commit

Permalink
Migrate to 0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
infomiho committed Jul 5, 2024
1 parent 85dce3f commit c5cff5b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 26 deletions.
32 changes: 8 additions & 24 deletions examples/todo-typescript/main.wasp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app TodoTypescript {
wasp: {
version: "^0.13.0"
version: "^0.14.0"
},
title: "ToDo TypeScript",

Expand All @@ -16,59 +16,43 @@ app TodoTypescript {
}
}

// Use Prisma Schema Language (PSL) to define our entities: https://www.prisma.io/docs/concepts/components/prisma-schema
// Run `wasp db migrate-dev` in the CLI to create the database tables
// Then run `wasp db studio` to open Prisma Studio and view your db models
entity User {=psl
id Int @id @default(autoincrement())
tasks Task[]
psl=}

entity Task {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
user User @relation(fields: [userId], references: [id])
userId Int
psl=}

route RootRoute { path: "/", to: MainPage }
page MainPage {
authRequired: true,
component: import { MainPage } from "@src/client/MainPage.tsx"
component: import { MainPage } from "@src/MainPage.tsx"
}

route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import { LoginPage } from "@src/client/LoginPage.tsx"
component: import { LoginPage } from "@src/LoginPage.tsx"
}

route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import { SignupPage } from "@src/client/SignupPage.tsx"
component: import { SignupPage } from "@src/SignupPage.tsx"
}

query getTasks {
// We specify the JS implementation of our query (which is an async JS function)
// Even if you use TS and have a queries.ts file, you will still need to import it using the .js extension.
// see here for more info: https://wasp-lang.dev/docs/tutorials/todo-app/03-listing-tasks#wasp-declaration
fn: import { getTasks } from "@src/server/queries.js",
fn: import { getTasks } from "@src/queries.js",
// We tell Wasp that this query is doing something with the `Task` entity. With that, Wasp will
// automatically refresh the results of this query when tasks change.
entities: [Task]
}

action createTask {
fn: import { createTask } from "@src/server/actions.js",
fn: import { createTask } from "@src/actions.js",
entities: [Task]
}

action updateTask {
fn: import { updateTask } from "@src/server/actions.js",
fn: import { updateTask } from "@src/actions.js",
entities: [Task]
}

action deleteTasks {
fn: import { deleteTasks } from "@src/server/actions.js",
fn: import { deleteTasks } from "@src/actions.js",
entities: [Task],
}
24 changes: 24 additions & 0 deletions examples/todo-typescript/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
}

// Use Prisma Schema file to define your entities: https://www.prisma.io/docs/concepts/components/prisma-schema
// Run `wasp db migrate-dev` in the CLI to create the database tables
// Then run `wasp db studio` to open Prisma Studio and view your db models
model User {
id Int @id @default(autoincrement())
tasks Task[]
}

model Task {
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
user User @relation(fields: [userId], references: [id])
userId Int
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const MainPage = ({ user }: { user: User }) => {
return (
<main>
<img src={waspLogo} alt="wasp logo" />
{user && (
{user && user.identities.username && (
<h1>
{getUsername(user)}
{user.identities.username.id}
{`'s tasks :)`}
</h1>
)}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes

0 comments on commit c5cff5b

Please sign in to comment.