Files
habitica/website/server/models/pushDevice.js
Matteo Pagliazzi 79c0499672 Mongoose: use $type as the typeKey (#10789)
* use $type as the typeKey in mongoose

* fix and add tests
2018-10-28 15:42:48 -05:00

23 lines
557 B
JavaScript

import mongoose from 'mongoose';
import baseModel from '../libs/baseModel';
const Schema = mongoose.Schema;
export let 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 let model = mongoose.model('PushDevice', schema);