networkinssch
WWasp
•Created by networkinssch on 3/3/2024 in #🙋questions
Add a new entity into the saas template
Thank you very much, that helped!
9 replies
WWasp
•Created by networkinssch on 3/3/2024 in #🙋questions
Add a new entity into the saas template
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
9 replies