34 lines
670 B
JavaScript
34 lines
670 B
JavaScript
|
"use strict";
|
||
|
|
||
|
const mongoose = require('mongoose');
|
||
|
const Schema = mongoose.Schema;
|
||
|
|
||
|
const PromotionSchema = new Schema({
|
||
|
userId: {
|
||
|
type: mongoose.Schema.Types.ObjectId,
|
||
|
ref: 'User'
|
||
|
},
|
||
|
proposer: {
|
||
|
type: mongoose.Schema.Types.ObjectId,
|
||
|
ref: 'AppUser',
|
||
|
required: true
|
||
|
},
|
||
|
rankLvl: {
|
||
|
type: Number,
|
||
|
get: v => Math.round(v),
|
||
|
set: v => Math.round(v),
|
||
|
required: true
|
||
|
},
|
||
|
confirmed: {
|
||
|
type: Boolean,
|
||
|
default: true
|
||
|
}
|
||
|
}, {
|
||
|
collection: 'promotion',
|
||
|
timestamps: {createdAt: 'timestamp'}
|
||
|
});
|
||
|
// optional more indices
|
||
|
PromotionSchema.index({timestamp: 1});
|
||
|
|
||
|
module.exports = mongoose.model('Promotion', PromotionSchema);
|