12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 文件夹表
- const dir = {
- name: { type: String },
- project: { type: String },
- super: { type: String },
- sort: { type: Number, default: 0 },
- remark: { type: String },
- };
- const schema = new Schema(dir, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ super: 1 });
- schema.index({ sort: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = (app) => {
- const { mongoose } = app;
- return mongoose.model('Dir', schema, 'dir');
- };
|