2020-10-23 15:51:57 +03:00
|
|
|
import HttpError from '@wasp/core/HttpError.js'
|
|
|
|
|
2020-10-12 16:03:07 +03:00
|
|
|
export const createTask = async ({ description }, context) => {
|
2020-10-23 15:51:57 +03:00
|
|
|
if (!context.user) { throw new HttpError(403) }
|
2020-10-12 16:03:07 +03:00
|
|
|
return context.entities.Task.create({
|
2020-10-23 15:51:57 +03:00
|
|
|
data: {
|
|
|
|
description,
|
|
|
|
user: { connect: { id: context.user.id } }
|
|
|
|
}
|
2020-10-12 16:03:07 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-10-23 15:51:57 +03:00
|
|
|
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 } },
|
2020-10-12 23:07:36 +03:00
|
|
|
data: {
|
2020-10-23 15:51:57 +03:00
|
|
|
isDone: data.isDone
|
2020-10-12 23:07:36 +03:00
|
|
|
}
|
2020-10-12 16:03:07 +03:00
|
|
|
})
|
|
|
|
}
|