1234567891011121314151617181920212223242526 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 积分表明细
- const point = {
- customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
- point: { type: Number, required: false, zh: '积分' }, // 整数
- time: { type: String, required: false, zh: '时间' }, //
- status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:point_status
- source: { type: String, required: false, zh: '来源' }, // 字典:point_source
- source_id: { type: String, required: false, zh: '来源id' }, //
- };
- const schema = new Schema(point, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ customer: 1 });
- schema.index({ status: 1 });
- schema.index({ source_id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Point', schema, 'point');
- };
|