fix(Models): add createdAt field

This commit is contained in:
Josepablo C
2024-04-06 15:43:49 -06:00
parent d00f7bbfa7
commit b68eebdbef
4 changed files with 6 additions and 1 deletions

View File

@@ -22,8 +22,9 @@ async function getUserById( id , filter ){
function getAndFilterList( query ){ function getAndFilterList( query ){
const filter_list = []; const filter_list = [];
const { permissions, gender, job_role, employee_id, company, branch, vehicle, active_load, categories } = query; const { email, permissions, gender, job_role, employee_id, company, branch, vehicle, active_load, categories } = query;
if( email ){ filter_list.push( { email } ); }
if( permissions ){ filter_list.push( { permissions } ); } if( permissions ){ filter_list.push( { permissions } ); }
if( gender ){ filter_list.push( { gender } ); } if( gender ){ filter_list.push( { gender } ); }
if( job_role ){ filter_list.push( { job_role } ); } if( job_role ){ filter_list.push( { job_role } ); }
@@ -158,6 +159,7 @@ async function createUserWithinCompany( companyId , data ){
employee_id employee_id
}); });
user.employee_id = employee_id;
return user; return user;
} }

View File

@@ -59,6 +59,7 @@ const schema = new Schema({
lng: { type: String }, lng: { type: String },
is_hidden: { type: Boolean, default: false }, is_hidden: { type: Boolean, default: false },
createdAt: { type : Date, required : true, default : () => { return Date.now(); } }
}); });
module.exports = mongoose.model( "companies", schema ); module.exports = mongoose.model( "companies", schema );

View File

@@ -85,6 +85,7 @@ const schema = new Schema({
payment_term: { type: String }, payment_term: { type: String },
terms_and_conditions: { type: String }, terms_and_conditions: { type: String },
createdAt: { type : Date, required : true, default : () => { return Date.now(); } }
}); });
module.exports = mongoose.model( "loads", schema ); module.exports = mongoose.model( "loads", schema );

View File

@@ -16,6 +16,7 @@ const schema = new Schema({
accepted_by: { type: Schema.Types.ObjectId, ref: 'users' }, accepted_by: { type: Schema.Types.ObjectId, ref: 'users' },
accepted_date: { type: Date }, accepted_date: { type: Date },
is_accepted: { type: Boolean, default: false }, is_accepted: { type: Boolean, default: false },
createdAt: { type : Date, required : true, default : () => { return Date.now(); } }
}); });
module.exports = mongoose.model( "proposals", schema ); module.exports = mongoose.model( "proposals", schema );