mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix(iap): wip
This commit is contained in:
22
website/server/models/iapPurchaseReceipt.js
Normal file
22
website/server/models/iapPurchaseReceipt.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import mongoose from 'mongoose';
|
||||
import baseModel from '../libs/api-v3/baseModel';
|
||||
import validator from 'validator';
|
||||
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
export let schema = new Schema({
|
||||
_id: {type: String, required: true}, // Use a custom string as _id
|
||||
consumed: {type: Boolean, default: false, required: true},
|
||||
userId: {type: String, ref: 'User', required: true, validate: [validator.isUUID, 'Invalid uuid.']},
|
||||
}, {
|
||||
strict: true,
|
||||
minimize: false, // So empty objects are returned
|
||||
});
|
||||
|
||||
schema.plugin(baseModel, {
|
||||
noSet: ['id', '_id', 'userId', 'consumed'], // Nothing can be set from the client
|
||||
timestamps: true,
|
||||
_id: false, // using custom _id
|
||||
});
|
||||
|
||||
export let model = mongoose.model('IapPurchaseReceipt', schema);
|
||||
Reference in New Issue
Block a user