Files

32 lines
698 B
JavaScript

import Model from "./model.js";
// Create
export const createEnquiry = async (data) => {
return await Model.create(data);
};
// Read (Get by ID)
export const getEnquiryById = async (id) => {
return await Model.findById(id);
};
// Read (Get by Query)
export const getEnquiryByQuery = async (query) => {
return await Model.findOne(query);
};
// Read (Get all)
export const getAllEnquiries = async (query) => {
return await Model.find(query);
};
// Update
export const updateEnquiry = async (id, data) => {
return await Model.findByIdAndUpdate(id, data, { new: true });
};
// Aggregate
export const aggregateEnquiry = async (pipeline) => {
return await Model.aggregate(pipeline);
};