location updates saved to db and base endpoints for other modules started
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
import { model, Schema, Types } from "mongoose";
|
||||
|
||||
const schema = new Schema({
|
||||
createdOn: {
|
||||
type: Date,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
export default model("branch", schema);
|
||||
@@ -33,7 +33,7 @@ const schema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: ["HQ", "Branch", "Warehouse", "BackOffice"],
|
||||
enum: ["HQ", "BRANCH", "WAREHOUSE"],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export const createLocation = async (data) => {
|
||||
return await Model.create({
|
||||
...data,
|
||||
coordinates: geoJson,
|
||||
createdOn: dayjs().toISOString(),
|
||||
createdOn: data?.recorded_at,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ export const getLocationById = async (id) => {
|
||||
|
||||
// Read (Get by Query)
|
||||
export const getLocationByQuery = async (query) => {
|
||||
return await Model.findOne(query);
|
||||
return await Model.findOne(query).sort({ createdOn: -1 });
|
||||
};
|
||||
|
||||
// Read (Get by Radius)
|
||||
|
||||
@@ -13,6 +13,10 @@ const schema = new Schema({
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
state: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
||||
@@ -25,6 +25,11 @@ const schema = new Schema({
|
||||
type: Date,
|
||||
required: true,
|
||||
},
|
||||
createdBy: {
|
||||
type: Types.ObjectId,
|
||||
required: true,
|
||||
ref: "user",
|
||||
},
|
||||
});
|
||||
|
||||
export default model("user", schema);
|
||||
|
||||
+18
-10
@@ -15,6 +15,22 @@ const schema = new Schema({
|
||||
type: Date,
|
||||
required: true,
|
||||
},
|
||||
address: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
city: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
state: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
pincode: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
location: locationSchema,
|
||||
category: {
|
||||
type: String,
|
||||
@@ -25,19 +41,11 @@ const schema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: [
|
||||
"HQ",
|
||||
"BRANCH",
|
||||
"WAREHOUSE",
|
||||
"VENDOR",
|
||||
"PARTNER",
|
||||
"DISTRIBUTOR",
|
||||
"CLIENT",
|
||||
],
|
||||
enum: ["HQ", "BRANCH", "WAREHOUSE"],
|
||||
},
|
||||
entity: {
|
||||
type: Types.ObjectId,
|
||||
required: true,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ export const getVenueById = async (id) => {
|
||||
// Read (Get by Query)
|
||||
export const getVenueByQuery = async (query) => {
|
||||
return await Model.findOne(query);
|
||||
}
|
||||
};
|
||||
|
||||
// Read (Get all)
|
||||
export const getAllVenues = async () => {
|
||||
return await Model.find();
|
||||
export const getAllVenues = async (query = {}) => {
|
||||
return await Model.find(query);
|
||||
};
|
||||
|
||||
// Update
|
||||
|
||||
@@ -19,3 +19,4 @@ export { default as Designation } from "./Designation/model";
|
||||
export { default as Inventory } from "./Inventory/model";
|
||||
export { default as InventoryLog } from "./InventoryLog/model";
|
||||
export { default as Role } from "./Role/model";
|
||||
export { default as Venue } from "./Venue/model";
|
||||
|
||||
Reference in New Issue
Block a user