65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
const uniqueValidator = require('mongoose-unique-validator');
|
|
module.exports = mongoose => {
|
|
var routeCustomerListSchema = mongoose.Schema({
|
|
customer_id: String,
|
|
customer_name: String,
|
|
customer_address: String,
|
|
customer_avatar: String,
|
|
customer_group: String,
|
|
customer_group_address: String,
|
|
customer_type: String,
|
|
customer_pickup_status: String,
|
|
customer_note: String,
|
|
customer_special_needs: String,
|
|
customer_phone: String,
|
|
customer_enter_center_time: Date,
|
|
customer_leave_center_time: Date,
|
|
customer_pickup_time: Date,
|
|
customer_dropoff_time: Date,
|
|
customer_route_status: String,
|
|
customer_pickup_order: Number,
|
|
customer_table_id: String,
|
|
customer_transfer_to_route: String,
|
|
customer_language: String,
|
|
customer_estimated_pickup_time: String,
|
|
customer_estimated_dropoff_time: String,
|
|
customer_address_override: String,
|
|
});
|
|
var checklistResultSchema = mongoose.Schema({
|
|
item: String,
|
|
result: Boolean
|
|
});
|
|
var schema = mongoose.Schema(
|
|
{
|
|
name: String,
|
|
schedule_date: String,
|
|
vehicle: String,
|
|
status: [{
|
|
type: String
|
|
}],
|
|
driver: String,
|
|
type: String,
|
|
start_mileage: Number,
|
|
end_mileage: Number,
|
|
start_time: Date,
|
|
end_time: Date,
|
|
estimated_start_time: Date,
|
|
route_customer_list: [{
|
|
type: routeCustomerListSchema
|
|
}],
|
|
checklist_result: [{
|
|
type: checklistResultSchema,
|
|
}],
|
|
site: Number
|
|
},
|
|
{ collection: 'route_path', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
schema.plugin(uniqueValidator);
|
|
const RoutePath = mongoose.model("route_path", schema);
|
|
return RoutePath;
|
|
}; |