12345678910111213141516171819202122232425262728 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const dateNow = function () {
- return moment().format("YYYY-MM-DD");
- };
- // 维修单
- const RepairSchema = {
- name: { type: String, required: false, maxLength: 200 }, // 维修项目名
- type: { type: String, required: false, maxLength: 200 }, // 类型
- parts: { type: String, required: false, maxLength: 200 }, // 配件
- jobdate: { type: String, required: false, maxLength: 200 }, // 工时
- totalmoney: { type: String, required: false, maxLength: 200 }, // 合计
- create_data: { type: String, required: false, maxLength: 200, default: dateNow }, // 来店时间
- finish_date: { type: String, required: false, maxLength: 200 }, // 交车时间
- uid: { type: String, required: true, maxLength: 500 }, // 所属用户id
- // ref:'Company',关联数据
- };
- const schema = new Schema(RepairSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Repair', schema, 'repair');
- };
|