point.js 1006 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 积分表明细
  5. const point = {
  6. customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
  7. point: { type: Number, required: false, zh: '积分' }, // 整数
  8. time: { type: String, required: false, zh: '时间' }, //
  9. status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:point_status
  10. source: { type: String, required: false, zh: '来源' }, // 字典:point_source
  11. source_id: { type: String, required: false, zh: '来源id' }, //
  12. };
  13. const schema = new Schema(point, { toJSON: { getters: true, virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ customer: 1 });
  17. schema.index({ status: 1 });
  18. schema.index({ source_id: 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('Point', schema, 'point');
  23. };