12345678910111213141516171819202122232425 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 图片路径
- const image = new Schema({
- url: { type: String, required: false, maxLength: 500 }, // 图片路径
- });
- // 企业信息表
- const company = {
- company: { type: String, required: true, maxLength: 200 }, // 企业名称
- engCompany: { type: String, required: true, maxLength: 200 }, // 英文名称
- brief: { type: String, required: true, maxLength: 200 }, // 简介
- imagearray: { type: [ image ], select: true, maxLength: 500 }, // 图片(数组)
- };
- const schema = new Schema(company, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Company', schema, 'company');
- };
|