123456789101112131415161718192021 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 产品表
- const product = {
- name: { type: String, required: true, maxLength: 200 }, // 名称
- filepath: { type: String, required: false, maxLength: 200 }, // 图片路径
- create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
- content: { type: String, required: false, maxLength: 500 }, // 内容
- brief: { type: String, required: false, maxLength: 500 }, // 简介
- };
- const schema = new Schema(product, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Product', schema, 'product');
- };
|