fix: vehicles, adding posted_by field
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { populate } = require("dotenv");
|
|
||||||
|
|
||||||
const { ROOT_PATH, LIB_PATH, MODELS_PATH, HANDLERS_PATH } = process.env;
|
const { ROOT_PATH, LIB_PATH, MODELS_PATH, HANDLERS_PATH } = process.env;
|
||||||
const { getModel } = require( `${ROOT_PATH}/${MODELS_PATH}` );
|
const { getModel } = require( `${ROOT_PATH}/${MODELS_PATH}` );
|
||||||
const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
|
const { getPagination } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ const patchVehicle = async(req, res) => {
|
|||||||
|
|
||||||
const postVehicle = async(req, res) => {
|
const postVehicle = async(req, res) => {
|
||||||
try{
|
try{
|
||||||
|
const userId = req.context.userId;
|
||||||
const companyId = req.context.companyId;
|
const companyId = req.context.companyId;
|
||||||
const permissions = req.context.permissions;
|
const permissions = req.context.permissions;
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
@@ -144,6 +145,7 @@ const postVehicle = async(req, res) => {
|
|||||||
data.company = companyId;
|
data.company = companyId;
|
||||||
data.status = "Free";
|
data.status = "Free";
|
||||||
data.is_available = false;
|
data.is_available = false;
|
||||||
|
data.posted_by = userId;
|
||||||
const vehicle = new Model( data );
|
const vehicle = new Model( data );
|
||||||
await vehicle.save();
|
await vehicle.save();
|
||||||
return res.send( vehicle );
|
return res.send( vehicle );
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const pointSchema = new Schema({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const schema = new Schema({
|
const schema = new Schema({
|
||||||
company: { type: Schema.Types.ObjectId, ref: 'companies' }, // carrier
|
company: { type: Schema.Types.ObjectId, ref: 'companies', required: true }, // carrier
|
||||||
|
|
||||||
vehicle_code: { type: String },
|
vehicle_code: { type: String },
|
||||||
vehicle_name: { type: String },
|
vehicle_name: { type: String },
|
||||||
@@ -33,6 +33,7 @@ const schema = new Schema({
|
|||||||
|
|
||||||
categories: [{ type: Schema.Types.ObjectId, ref: 'productcategories' }],
|
categories: [{ type: Schema.Types.ObjectId, ref: 'productcategories' }],
|
||||||
|
|
||||||
|
posted_by: { type: Schema.Types.ObjectId, ref: 'users', required: true }, // carrier
|
||||||
published_date: { type: Date },
|
published_date: { type: Date },
|
||||||
available_date: { type: String },
|
available_date: { type: String },
|
||||||
is_available: { type: Boolean, default: false },
|
is_available: { type: Boolean, default: false },
|
||||||
|
|||||||
Reference in New Issue
Block a user