space.js 764 B

12345678910111213141516171819202122
  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 space = {
  8. name: { type: String }, // 场地名
  9. price: { type: Number, default: 0 }, // 价格
  10. images: { type: Array }, // 场地图片
  11. is_use: { type: Boolean, default: true }, // 场地是否使用
  12. remark: { type: String },
  13. };
  14. const schema = new Schema(space, { 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('Space', schema, 'space');
  22. };