12345678910111213141516171819202122 |
- '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 space = {
- name: { type: String }, // 场地名
- price: { type: Number, default: 0 }, // 价格
- images: { type: Array }, // 场地图片
- is_use: { type: Boolean, default: true }, // 场地是否使用
- remark: { type: String },
- };
- const schema = new Schema(space, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ name: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Space', schema, 'space');
- };
|