1234567891011121314151617181920212223242526272829 |
- '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 object = new Schema({
- time: { type: Array }, // 时间
- money: { type: Number, default: 0 }, // 金额
- space_id: { type: ObjectId }, // 场地id
- is_use: { type: Boolean, default: true }, // 0-允许使用;1-禁止使用
- });
- // 场地安排表
- const arrange = {
- date: { type: String }, // 日期
- arrange: { type: [ object ] }, // 安排
- remark: { type: String },
- };
- const schema = new Schema(arrange, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ date: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Arrange', schema, 'arrange');
- };
|