cubub
WWasp
•Created by david.fejes on 3/12/2024 in #đŸ™‹questions
Object relation doesn't compile to TypeScript
Wow! it works perfectly. Thank you very much for your support @genyus .
Turn out I made the action markTaskAsDone and query getFilteredTask by using wrong operations (updateTask and getTasks). But it still works as normal so I think that is the direction to go.
I must careful next time.
54 replies
WWasp
•Created by david.fejes on 3/12/2024 in #đŸ™‹questions
Object relation doesn't compile to TypeScript
I have changed as you suggested, but the error log is still the same, so I dont think that is the reason. Other 3 files that cause similar troubles also do not have the "include". Here is my repo: https://github.com/cubu/wasprelations/tree/main/src/api/v1/modules/tags
54 replies
WWasp
•Created by david.fejes on 3/12/2024 in #đŸ™‹questions
Object relation doesn't compile to TypeScript
And here is the model in schema.prisma:
model Task {
id String @id @default(cuid())
description String
isDone Boolean @default(false)
tags Tag[] @relation("TaskTags") // Many-to-many relation with Tag } model Tag { id String @id @default(cuid()) name String tasks Task[] @relation("TaskTags") // Many-to-many relation with Task }
tags Tag[] @relation("TaskTags") // Many-to-many relation with Tag } model Tag { id String @id @default(cuid()) name String tasks Task[] @relation("TaskTags") // Many-to-many relation with Task }
54 replies
WWasp
•Created by david.fejes on 3/12/2024 in #đŸ™‹questions
Object relation doesn't compile to TypeScript
No, i use implicit many to many relation as prisma suggested since there is no extra information need to be stored. It is just a tag for task. I also dont see anywhere in wasp documentation state that we need to use explicit relation
54 replies
WWasp
•Created by david.fejes on 3/12/2024 in #đŸ™‹questions
Object relation doesn't compile to TypeScript
@kapa.ai can you suggest me with above problem?
54 replies
WWasp
•Created by david.fejes on 3/12/2024 in #đŸ™‹questions
Object relation doesn't compile to TypeScript
@kapa.ai Not sure If it might related, my usecase is implicit many to many relation, with Task and Tag model (1 Tag can belong to multiple Tasks; and one Task can help multiple Tags). The intelisense show no error but the console log denied to compiled:
[ Wasp ] server/operations/actions/index.ts(150,7): error TS2353: Object literal may only specify known properties, and 'Tag' does not exist in type '{ Task: TaskDelegate<DefaultArgs>; }'.
[ Wasp ] server/operations/actions/index.ts(163,7): error TS2353: Object literal may only specify known properties, and 'Tag' does not exist in type '{ Task: TaskDelegate<DefaultArgs>; }'.
[ Wasp ] server/operations/queries/index.ts(89,7): error TS2353: Object literal may only specify known properties, and 'Tag' does not exist in type '{ Task: TaskDelegate<DefaultArgs>; }'.
[ Wasp ] server/operations/queries/index.ts(102,7): error TS2353: Object literal may only specify known properties, and 'Tag' does not exist in type '{ Task: TaskDelegate<DefaultArgs>; }'.
This is due to 4 queries and actions:
- getTasksForTag
- getTagsForTask
- assignTagToTask
- removeTagFromTask
Below is one query:
getTagsForTask:
import { Tag } from 'wasp/entities'
import { type GetTasks } from 'wasp/server/operations'
type GetTagsForTaskPayload = { taskId: string }
export const getTagsForTask: GetTasks<GetTagsForTaskPayload, Tag[]> = async ({ taskId }, context) => { const task = await context.entities.Task.findUnique({ where: { id: taskId }, select: { tags: true }, })
return task?.tags || [] } Obiviously I have already include it in main.wasp: query getTagsForTask { fn: import { getTagsForTask } from "@src/server/queries.ts", entities: [Task, Tag] } Any clues on that? @kapa.ai
type GetTagsForTaskPayload = { taskId: string }
export const getTagsForTask: GetTasks<GetTagsForTaskPayload, Tag[]> = async ({ taskId }, context) => { const task = await context.entities.Task.findUnique({ where: { id: taskId }, select: { tags: true }, })
return task?.tags || [] } Obiviously I have already include it in main.wasp: query getTagsForTask { fn: import { getTagsForTask } from "@src/server/queries.ts", entities: [Task, Tag] } Any clues on that? @kapa.ai
54 replies
WWasp
•Created by samidev on 10/11/2023 in #đŸ™‹questions
WASP NOT ISNTALLING
install WSL and remote connect to it through VS code
4 replies
WWasp
•Created by Virusthe on 9/1/2023 in #đŸ™‹questions
How do I get daisyui to work?
Have you added ("daisyui", "^3.6.4") to dependencies array in main.wasp file?
13 replies
WWasp
•Created by cubub on 8/6/2023 in #đŸ™‹questions
Many to Many relationship example?
Thank you @Fecony , I can do the modeling part with Prisma (with explicit relation). What I'm looking for is the sample code of queries and actions so it can save me as bit of time learning it faster. Nvm, I will have to do it if there is nothing exist btw.
6 replies