present.js 531 B

12345678910111213141516
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const Present = {
  5. name: { type: String, required: true, maxLength: 200 }, // 礼物名称
  6. price: { type: String, required: true, maxLength: 200 }, // 金额
  7. };
  8. const schema = new Schema(Present, { toJSON: { virtuals: true } });
  9. schema.index({ id: 1 });
  10. schema.plugin(metaPlugin);
  11. module.exports = app => {
  12. const { mongoose } = app;
  13. return mongoose.model('present', schema, 'present');
  14. };