tenant.js 865 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 站点表
  7. const tenant = {
  8. _tenant: { type: String, require: true }, // 站点
  9. name: { type: String }, // 站点名称
  10. params: { type: Object }, // 参数
  11. is_use: { type: Boolean, default: true }, // 是否使用
  12. img: { type: Object }, // 图片设置
  13. remark: { type: String },
  14. };
  15. const schema = new Schema(tenant, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ _tenant: 1 });
  18. schema.index({ name: 1 });
  19. schema.index({ is_use: 1 });
  20. schema.index({ 'meta.createdAt': 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Tenant', schema, 'tenant');
  25. };