123456789101112131415161718192021222324252627 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 客服状态表
- const status = {
- customer_id: { type: ObjectId }, // 客服id
- customer_name: { type: String }, // 客服名
- status: { type: String, default: '0' }, // 状态:0-空闲;1-接待中
- _tenant: { type: String, default: 'master' }, // 哪个项目
- logout_time: { type: String }, // 失效时间
- remark: { type: String },
- };
- const schema = new Schema(status, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ customer_id: 1 });
- schema.index({ customer_name: 1 });
- schema.index({ status: 1 });
- schema.index({ _tenant: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Status', schema, 'status');
- };
- // 定期进行清除
|