Files
cadhub/api/src/services/comments/comments.js
Kurt Hutten 9db76458d1 Revert "Move app into app directory"
This reverts commit 5c53902caf.
2021-05-01 07:29:45 +10:00

39 lines
832 B
JavaScript

import { db } from 'src/lib/db'
import { foreignKeyReplacement } from 'src/services/helpers'
export const comments = () => {
return db.comment.findMany()
}
export const comment = ({ id }) => {
return db.comment.findUnique({
where: { id },
})
}
export const createComment = ({ input }) => {
return db.comment.create({
data: foreignKeyReplacement(input),
})
}
export const updateComment = ({ id, input }) => {
return db.comment.update({
data: foreignKeyReplacement(input),
where: { id },
})
}
export const deleteComment = ({ id }) => {
return db.comment.delete({
where: { id },
})
}
export const Comment = {
user: (_obj, { root }) =>
db.comment.findUnique({ where: { id: root.id } }).user(),
part: (_obj, { root }) =>
db.comment.findUnique({ where: { id: root.id } }).part(),
}