34 lines
856 B
JavaScript
34 lines
856 B
JavaScript
const { Notifications, NotificationCodes } = require("../models/Notifications");
|
|
const { repairNotifications } = require("./queryProccess");
|
|
|
|
exports.getNotifications = async function({userId}){
|
|
return await Notifications.findAll({
|
|
where: {
|
|
userId: userId
|
|
},
|
|
include: {
|
|
model: NotificationCodes,
|
|
attributes: ["code"]
|
|
},
|
|
order: [["createdAt", "DESC"]],
|
|
limit: 7
|
|
});
|
|
};
|
|
|
|
exports.getNotificationUnread = async function({userId}){
|
|
return await Notifications.findAll({
|
|
where: {
|
|
userId: userId,
|
|
read: false
|
|
},
|
|
include: NotificationCodes
|
|
});
|
|
};
|
|
|
|
exports.getNotificationCode = async function({draftCode}){
|
|
return await NotificationCodes.findOne({
|
|
where: {
|
|
code: draftCode
|
|
}
|
|
});
|
|
}; |