123456789101112131415161718192021222324252627 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 留言
- const leavemess = {
- name: { type: String, required: false, zh: '姓名' }, //
- phone: { type: String, required: false, zh: '联系电话' }, //
- email: { type: String, required: false, zh: '电子邮箱' }, //
- content: { type: String, required: false, zh: '留言内容' }, //
- is_handle: { type: String, required: false, default: '0', zh: '是否处理' }, //
- };
- const schema = new Schema(leavemess, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ name: 1 });
- schema.index({ phone: 1 });
- schema.index({ email: 1 });
- schema.index({ is_handle: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Leavemess', schema, 'leavemess');
- };
|