place.js 721 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 馆管理
  5. const place = {
  6. name: { type: String }, // 名称
  7. center: { type: Array }, // 中心点
  8. desc: { type: String }, // 简述
  9. config: { type: Object }, // 设置
  10. pic: { type: Array }, // 图片
  11. plan_word: { type: String }, // 保安方案
  12. remark: { type: String },
  13. };
  14. const schema = new Schema(place, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ name: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Place', schema, 'place');
  22. };