mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
23 lines
562 B
JavaScript
23 lines
562 B
JavaScript
import mongoose from 'mongoose';
|
|
import baseModel from '../libs/baseModel';
|
|
|
|
const { Schema } = mongoose;
|
|
|
|
export const schema = new Schema({
|
|
regId: { $type: String, required: true },
|
|
type: { $type: String, required: true, enum: ['ios', 'android'] },
|
|
}, {
|
|
strict: true,
|
|
minimize: false, // So empty objects are returned
|
|
_id: false,
|
|
typeKey: '$type', // So that we can use a field named `type`
|
|
});
|
|
|
|
schema.plugin(baseModel, {
|
|
noSet: ['_id', 'regId'],
|
|
timestamps: true,
|
|
_id: false,
|
|
});
|
|
|
|
export const model = mongoose.model('PushDevice', schema);
|