123456789101112131415161718 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 项目表
- const project = {
- name: { type: String, required: true }, // 项目名称
- desc: { type: String }, // 描述
- remark: { type: String },
- };
- const schema = new Schema(project, { 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('Project', schema, 'project');
- };
|