12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 学校
- const school = {
- name: { type: String, required: false, zh: '名称' }, //
- brief: { type: String, required: false, zh: '简介' }, //
- img_url: { type: Array, required: false, zh: '图片' }, //
- user_id: { type: String, required: false, zh: '用户表信息', ref: 'User', getProp: [ 'name' ] }, //
- };
- const schema = new Schema(school, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ name: 1 });
- schema.index({ user_id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('School', schema, 'school');
- };
|