Mongoose: use $type as the typeKey (#10789)

* use $type as the typeKey in mongoose

* fix and add tests
This commit is contained in:
Matteo Pagliazzi
2018-10-28 15:23:41 +01:00
committed by Sabe Jones
parent 490531cc76
commit 79c0499672
15 changed files with 383 additions and 357 deletions

View File

@@ -5,7 +5,7 @@ import baseModel from '../libs/baseModel';
// A collection used to store mailing list unsubscription for non registered email addresses
export let schema = new mongoose.Schema({
email: {
type: String,
$type: String,
required: true,
trim: true,
lowercase: true,
@@ -14,6 +14,7 @@ export let schema = new mongoose.Schema({
}, {
strict: true,
minimize: false, // So empty objects are returned
typeKey: '$type', // So that we can use fields named `type`
});
schema.plugin(baseModel, {