position.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 定位信息表
  7. const position = {
  8. user_id: { type: String },
  9. company_id: { type: String }, // 企业id
  10. company_name: { type: String }, // 企业名
  11. longitude: { type: String }, // 经度
  12. latitude: { type: String }, // 纬度
  13. name: { type: String }, // 姓名
  14. card: { type: String }, // 身份证号
  15. is_class: { type: String }, // 是否在岗: 在岗/下班
  16. company_service_object_id: { type: String }, // 服务对象id
  17. company_service_object_name: { type: String }, // 服务对象
  18. info: { type: Object }, // 工牌定位额外信息
  19. remark: { type: String },
  20. };
  21. const schema = new Schema(position, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.index({ user_id: 1 });
  24. schema.index({ company_id: 1 });
  25. schema.index({ company_name: 1 });
  26. schema.index({ name: 1 });
  27. schema.index({ card: 1 });
  28. schema.index({ is_class: 1 });
  29. schema.index({ company_service_object_id: 1 });
  30. schema.index({ company_service_object_name: 1 });
  31. schema.index({ 'meta.createdAt': 1 });
  32. schema.plugin(metaPlugin);
  33. module.exports = app => {
  34. const { mongoose } = app;
  35. return mongoose.model('Position', schema, 'position');
  36. };