test.js 765 B

1234567891011121314151617181920
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 测试接口
  5. const TestSchema = {
  6. name: { type: String, required: true, maxLength: 200 }, // 姓名
  7. mobile: { type: String, required: true, maxLength: 200 }, // 电话
  8. qqwx: { type: String, required: true, maxLength: 200 }, // qq/微信
  9. email: { type: String, required: true, maxLength: 200 }, // 电子邮箱
  10. address: { type: String, required: true, maxLength: 200 }, // 联系地址
  11. };
  12. const schema = new Schema(TestSchema, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Test', schema, 'test');
  18. };