Files
fielderp-server/models/Vendor/operations.js
T

37 lines
802 B
JavaScript

import Model from "./model.js";
// Create
export const createVendor = async (data) => {
return await Model.create(data);
};
// Read (Get by ID)
export const getVendorById = async (id) => {
return await Model.findById(id);
};
// Read (Get One by Query)
export const getVendorByQuery = async (query) => {
return await Model.findOne(query);
};
// Read (Get All by Query)
export const getVendorsByQuery = async (query) => {
return await Model.find(query);
};
// Read (Get all)
export const getAllVendors = async () => {
return await Model.find();
};
// Update
export const updateVendor = async (id, data) => {
return await Model.findByIdAndUpdate(id, data, { new: true });
};
// Aggregate
export const aggregateVendor = async (pipeline) => {
return await Model.aggregate(pipeline);
};