123456789101112131415161718192021222324252627282930313233343536 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 定位信息表
- const position = {
- user_id: { type: String },
- company_id: { type: String }, // 企业id
- company_name: { type: String }, // 企业名
- longitude: { type: String }, // 经度
- latitude: { type: String }, // 纬度
- name: { type: String }, // 姓名
- card: { type: String }, // 身份证号
- is_class: { type: String }, // 是否在岗: 在岗/下班
- company_service_object_id: { type: String }, // 服务对象id
- company_service_object_name: { type: String }, // 服务对象
- info: { type: Object }, // 工牌定位额外信息
- remark: { type: String },
- };
- const schema = new Schema(position, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ user_id: 1 });
- schema.index({ company_id: 1 });
- schema.index({ company_name: 1 });
- schema.index({ name: 1 });
- schema.index({ card: 1 });
- schema.index({ is_class: 1 });
- schema.index({ company_service_object_id: 1 });
- schema.index({ company_service_object_name: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Position', schema, 'position');
- };
|