32 lines
690 B
JavaScript
32 lines
690 B
JavaScript
import Model from "./model.js";
|
|
|
|
// Create
|
|
export const createProfile = async (data) => {
|
|
return await Model.create(data);
|
|
};
|
|
|
|
// Read (Get by ID)
|
|
export const getProfileById = async (id) => {
|
|
return await Model.findById(id);
|
|
};
|
|
|
|
// Read (Get by Query)
|
|
export const getProfileByQuery = async (query) => {
|
|
return await Model.findOne(query);
|
|
};
|
|
|
|
// Read (Get all)
|
|
export const getAllProfiles = async () => {
|
|
return await Model.find();
|
|
};
|
|
|
|
// Update
|
|
export const updateProfile = async (id, data, options) => {
|
|
return await Model.findByIdAndUpdate(id, data, options);
|
|
};
|
|
|
|
// Aggregate
|
|
export const aggregateProfile = async (pipeline) => {
|
|
return await Model.aggregate(pipeline);
|
|
};
|