12345678910111213141516171819202122232425 |
- '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 }, // 站点名称
- params: { type: Object }, // 参数
- is_use: { type: Boolean, default: true }, // 是否使用
- img: { type: Object }, // 图片设置
- 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');
- };
|