12345678910111213141516171819202122232425 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 领劵记录
- const userCoupon = {
- customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
- shop: { type: String, required: false, zh: '发行店铺', ref: 'Shop.Shop' }, //
- coupon: { type: Object, required: false, zh: '优惠券' }, //
- status: { type: String, required: false, default: '0', zh: '是否使用' }, //
- };
- const schema = new Schema(userCoupon, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ customer: 1 });
- schema.index({ shop: 1 });
- schema.index({ coupon: 1 });
- schema.index({ status: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('UserCoupon', schema, 'userCoupon');
- };
|