Re-init DB and scaffold all models

This commit is contained in:
Kurt Hutten
2020-11-02 07:02:11 +11:00
parent 55f9dfd6de
commit 86df1d501d
97 changed files with 3202 additions and 2122 deletions

View File

@@ -0,0 +1,38 @@
import { db } from 'src/lib/db'
export const users = () => {
return db.user.findMany()
}
export const user = ({ id }) => {
return db.user.findOne({
where: { id },
})
}
export const createUser = ({ input }) => {
return db.user.create({
data: input,
})
}
export const updateUser = ({ id, input }) => {
return db.user.update({
data: input,
where: { id },
})
}
export const deleteUser = ({ id }) => {
return db.user.delete({
where: { id },
})
}
export const User = {
Part: (_obj, { root }) => db.user.findOne({ where: { id: root.id } }).Part(),
Reaction: (_obj, { root }) =>
db.user.findOne({ where: { id: root.id } }).Reaction(),
Comment: (_obj, { root }) =>
db.user.findOne({ where: { id: root.id } }).Comment(),
}