const notificationModel = require("../models/notfication");

const createNotification = async (notificationData) => {
    const { userId, adminId, orderId, message } = notificationData;
    const newNotification = new notificationModel({
        userId: userId,
        adminId: adminId,
        orderId: orderId,
        message: message
    });
    const result = await newNotification.save();
    return result;
};

const getNotifications = async (req) => {
    // const { userId, adminId } = req.query;
    const filter = {}
    if(req.query.userId){
        filter.userId = req.query.userId
    };
    if(req.query.adminId){
        filter.adminId = req.query.adminId
    };
    const result = await notificationModel.find(filter);
    return result
};

module.exports = {
    createNotification,
    getNotifications
};