module.exports = mongoose => { var schema = mongoose.Schema( { username: String, name_cn: String, email: String, password: String, roles: [{ type: String }], mobile_phone: String, home_phone: String, language: String, employment_status: String, address: String, date_hired: String, driver_capacity: Number, create_by: String, create_date: Date, edit_by: String, edit_date: Date, note: String, tags: [{ type: String }], fetch_route_time: Date, site: Number, // new fields added and legacy feilds are used in HR system trinet_id: String, name: String, firstname: String, middlename: String, lastname: String, preferred_name: String, ssn: String, marital_status: String, gender: String, city: String, street_address: String, state: String, zip: String, country: String, work_email: String, personal_email: String, phone: String, work_phone: String, birth_date: String, // date of birth work_phone_ext: String, // work phone extension dietary_restrictions: String, tshirt_size: String, title: String, title_cn: String, department: String, manager_name: String, manager_email: String, manager_trinet_id: String, manager_id: String, direct_reports: [{ type: String }], current_employment_start_date: String, initial_employment_start_date: String, status: String, work_location: String, employment_type: String, employment_start_date: String, employment_end_date: String, termination_date: String, termination_type: String, termination_reason: String, full_time_start_date: String, end_date: String, month_of_service: Number, full_years_of_service: Number, compensation_type: String, compensation: Number, worker_type: String, monthly_salary: Number, currency: String, salary: Number, hourly_wage: Number, work_site: Number, next_anniversary: Number, job_id: String, job_title: String, job_category: String, add_to_payroll: Boolean, collect_tax_information: Boolean, fingerprints: [{ type: String }], entry_passcode: [{ type: String }] }, { collection: 'employee', timestamps: true } ); schema.method("toJSON", function() { const { __v, _id, ...object } = this.toObject(); object.id = _id; return object; }); schema.index({username: 1, email: 1, site:1}, {unique: true}); const Employee = mongoose.model("employee", schema); return Employee; };