'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 tenant = { _tenant: { type: String, require: true }, // 站点 name: { type: String }, // 站点名称 is_use: { type: Boolean, default: true }, // 是否使用 remark: { type: String }, }; const schema = new Schema(tenant, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ _tenant: 1 }); schema.index({ name: 1 }); schema.index({ is_use: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Tenant', schema, 'tenant'); };