2022-02-17 17:23:43 +00:00
|
|
|
export default {
|
|
|
|
Query: {
|
2022-05-09 17:30:27 +00:00
|
|
|
sub: async (parent, { name }, { models, me }) => {
|
2023-07-23 15:08:43 +00:00
|
|
|
if (!name) return null
|
|
|
|
|
2022-05-09 17:30:27 +00:00
|
|
|
if (me && name === 'jobs') {
|
|
|
|
models.user.update({
|
|
|
|
where: {
|
|
|
|
id: me.id
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
lastCheckedJobs: new Date()
|
|
|
|
}
|
|
|
|
}).catch(console.log)
|
|
|
|
}
|
|
|
|
|
2022-02-17 17:23:43 +00:00
|
|
|
return await models.sub.findUnique({
|
|
|
|
where: {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
})
|
2022-05-09 17:30:27 +00:00
|
|
|
},
|
|
|
|
subLatestPost: async (parent, { name }, { models, me }) => {
|
|
|
|
const latest = await models.item.findFirst({
|
|
|
|
where: {
|
|
|
|
subName: name
|
|
|
|
},
|
|
|
|
orderBy: {
|
|
|
|
createdAt: 'desc'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-07-30 13:25:46 +00:00
|
|
|
return latest?.createdAt
|
2022-02-17 17:23:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|