stacker.news/api/resolvers/sub.js

35 lines
689 B
JavaScript

export default {
Query: {
sub: async (parent, { name }, { models, me }) => {
if (me && name === 'jobs') {
models.user.update({
where: {
id: me.id
},
data: {
lastCheckedJobs: new Date()
}
}).catch(console.log)
}
return await models.sub.findUnique({
where: {
name
}
})
},
subLatestPost: async (parent, { name }, { models, me }) => {
const latest = await models.item.findFirst({
where: {
subName: name
},
orderBy: {
createdAt: 'desc'
}
})
return latest?.createdAt
}
}
}