mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-18 22:51:40 +03:00
22 lines
565 B
JavaScript
22 lines
565 B
JavaScript
import HttpError from '@wasp/core/HttpError.js'
|
|
|
|
export const createTask = async ({ description }, context) => {
|
|
if (!context.user) { throw new HttpError(403) }
|
|
return context.entities.Task.create({
|
|
data: {
|
|
description,
|
|
user: { connect: { id: context.user.id } }
|
|
}
|
|
})
|
|
}
|
|
|
|
export const updateTask = async ({ taskId, data }, context) => {
|
|
if (!context.user) { throw new HttpError(403) }
|
|
return context.entities.Task.updateMany({
|
|
where: { id: taskId, user: { id: context.user.id } },
|
|
data: {
|
|
isDone: data.isDone
|
|
}
|
|
})
|
|
}
|