reinitializing codebase and resuming development

This commit is contained in:
Shibi Chakkaravarthy
2026-09-27 00:48:18 +05:30
parent 5e894627f5
commit be7211ac28
23 changed files with 744 additions and 45 deletions
+25
View File
@@ -0,0 +1,25 @@
import { model, Schema, Types } from "mongoose";
const schema = new Schema({
createdOn: {
type: Date,
required: true,
},
user: {
type: Types.ObjectId,
required: true,
ref: "user",
},
venue: {
type: Types.ObjectId,
required: true,
ref: "venue",
},
assignment: {
type: Types.ObjectId,
required: true,
ref: "assignment",
},
});
export default model("visit", schema);
+31
View File
@@ -0,0 +1,31 @@
import Model from "./model.js";
// Create
export const createVisit = async (data) => {
return await Model.create(data);
};
// Read (Get by ID)
export const getVisitById = async (id) => {
return await Model.findById(id);
};
// Read (Get by Query)
export const getVisitByQuery = async (query) => {
return await Model.findOne(query);
}
// Read (Get all)
export const getAllVisits = async () => {
return await Model.find();
};
// Update
export const updateVisit = async (id, data) => {
return await Model.findByIdAndUpdate(id, data, { new: true });
};
// Aggregate
export const aggregateVisit = async (pipeline) => {
return await Model.aggregate(pipeline);
};