Add a new entity into the saas template

I copied Task and gave it a new name (=workflow). Now it fails during the wasp db migrate-dev. It has a problem with the new action CreateWorkflow with the data object. It seems to miss some of the new fields like workflowname. Where do I need to adjust that ? Error message: Type '{ workflowname: string; user: { connect: { id: number; }; }; }' is missing the following properties from type 'WorkflowCreateInput': description, lastrunAt
5 Replies
Vinny (@Wasp)
Vinny (@Wasp)•3mo ago
Hey :boi: Can you share your entire workflow entity and the action as well?
networkinssch
networkinssch•3mo ago
Sure, here you go: Entity: entity Workflow {=psl id String @id @default(uuid()) workflowname String description String time Int @default(0) isSuccess Boolean @default(false) user User @relation(fields: [userId], references: [id]) userId Int createdAt DateTime @default(now()) updateddAt DateTime @default(now()) lastrunAt DateTime psl=} wasp operation: action createWorkflow { fn: import { createWorkflow } from "@src/server/actions.js", entities: [Workflow] } action.ts The line 76 with data: { is making the problem: export const createWorkflow: CreateWorkflow<Pick<Workflow, 'workflowname'>, Workflow> = async ({ workflowname }, context) => { if (!context.user) { throw new HttpError(401); } const workflow = await context.entities.Workflow.create({ data: { workflowname, user: { connect: { id: context.user.id } }, }, }); return workflow; }; Error message from wasp db migrate-dev: 🐝 --- Building SDK... ------------------------------------------------------------ [ Wasp ] ext-src/server/actions.ts(76,5): error TS2322: Type '{ workflowname: string; user: { connect: { id: number; }; }; }' is not assignable to type '(Without<WorkflowCreateInput, WorkflowUncheckedCreateInput> & WorkflowUncheckedCreateInput) | (Without<...> & WorkflowCreateInput)'. [ Wasp ] Type '{ workflowname: string; user: { connect: { id: number; }; }; }' is not assignable to type 'Without<WorkflowUncheckedCreateInput, WorkflowCreateInput> & WorkflowCreateInput'. [ Wasp ] Type '{ workflowname: string; user: { connect: { id: number; }; }; }' is missing the following properties from type 'WorkflowCreateInput': description, lastrunAt
Vinny (@Wasp)
Vinny (@Wasp)•3mo ago
Ok so it looks like you’re trying to create a workflow and you’re not giving it all the other properties it needs you need to pass it a description as you haven’t given it a default value or at least made it optional, description String? Btw when you pass in code, use three backticks ` before and after the code to format it so it looks like this
Some code goes here
Yay
Some code goes here
Yay
networkinssch
networkinssch•3mo ago
Thank you very much, that helped!
MEE6
MEE6•3mo ago
Wohooo @networkinssch, you just became a Waspeteer level 1!