location controller updated with heading and created new models and controllers for remaining modules

This commit is contained in:
Shibi Chakkaravarthy
2026-05-04 20:57:03 +05:30
parent 1245e09111
commit 54d9508dc8
31 changed files with 2140 additions and 96 deletions
+11 -2
View File
@@ -11,7 +11,7 @@ import {
import dayjs from "dayjs";
import mongoose from "mongoose";
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
import bcrypt from "bcryptjs";
import bcrypt from "bcrypt";
export const createEmployee = async (req, res) => {
const session = await mongoose.startSession();
@@ -41,7 +41,7 @@ export const createEmployee = async (req, res) => {
throw { code: 400, message: "ID already assigned for Another Employee" };
}
const employee = await User.create(
const [employee] = await User.create(
[
{
name,
@@ -49,11 +49,15 @@ export const createEmployee = async (req, res) => {
hash,
createdOn: dayjs().toISOString(),
createdBy: user.id,
isFirstTime: true,
isActive: true,
},
],
{ session },
);
console.log("EMPLOYEE", employee);
const profile = await Profile.create(
[
{
@@ -83,8 +87,13 @@ export const createEmployee = async (req, res) => {
],
{ session },
);
await session.commitTransaction();
session.endSession();
res.status(200).json({ result: access });
} catch (error) {
console.log("createEmployee Error", error);
await session.abortTransaction();
session.endSession();
res.status(500).json({ error: error.message });
}
};