full
This commit is contained in:
64
models/GiftModel.js
Normal file
64
models/GiftModel.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const mongoose = require('mongoose')
|
||||
const mongoosePaginate = require('mongoose-paginate-v2')
|
||||
const timestamp = require('mongoose-timestamp')
|
||||
|
||||
const giftSchema = new mongoose.Schema({
|
||||
sender: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true
|
||||
},
|
||||
receiver: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'User',
|
||||
required: true
|
||||
},
|
||||
amount: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
message: {
|
||||
type: String,
|
||||
trim: true,
|
||||
maxLength: 500,
|
||||
default: null
|
||||
},
|
||||
reply: {
|
||||
type: String,
|
||||
trim: true,
|
||||
maxLength: 500,
|
||||
default: null
|
||||
},
|
||||
repliedAt: {
|
||||
type: Date,
|
||||
default: null
|
||||
},
|
||||
transaction_id: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Payment',
|
||||
default: null
|
||||
},
|
||||
paymentMethod: {
|
||||
type: String,
|
||||
enum: ['online', 'wallet'],
|
||||
default: 'online'
|
||||
},
|
||||
viaChatMessage: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
opened: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
openedAt: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
})
|
||||
|
||||
giftSchema.plugin(timestamp)
|
||||
giftSchema.plugin(mongoosePaginate)
|
||||
|
||||
const GiftModel = mongoose.model('Gift', giftSchema)
|
||||
module.exports = GiftModel
|
||||
Reference in New Issue
Block a user