Node/modules/notifications/middlewares/query.js
Batuhan Coşkun 88839b0f4d Güncelleme
2025-03-20 13:28:23 +03:00

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
}
});
};