Revert "Fixed #1076, and all other instances of empty objects being stripped out of documents. Turns out mongoose was doing this intentionally as a feature? I don't understand why that's on by default. Oh mongoose."

Saw that this caused 500s on /auth/whoami with no cookies set, with this error:

debug: 500: MongoError: E11000 duplicate key error index: coco.users.$emailLower_1 dup key: { : null }

Probably we need to be much more careful about what changes this blanket change to the minimize Mongoose option might introduce, since tests didn't catch this, but it would have taken the site down for anyone not logged in already.

This reverts commit 121f07d020.
This commit is contained in:
Nick Winter 2015-01-09 18:30:05 -08:00
parent 82eb47bf5f
commit 58716f5b75
19 changed files with 20 additions and 20 deletions

View file

@ -13,7 +13,7 @@ TreemaUtils = require '../../bower_components/treema/treema-utils.js'
AchievementSchema = new mongoose.Schema({
userField: String
}, {strict: false, minimize: false})
}, {strict: false})
AchievementSchema.methods.objectifyQuery = ->
try

View file

@ -5,7 +5,7 @@ AnalyticsLogEventSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
AnalyticsLogEventSchema.index({event: 1, created: -1})
module.exports = AnalyticsLogEvent = mongoose.model('analytics.log.event', AnalyticsLogEventSchema)

View file

@ -5,6 +5,6 @@ AnalyticsUsersActiveSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
module.exports = AnalyticsUsersActive = mongoose.model('analytics.users.active', AnalyticsUsersActiveSchema)

View file

@ -1,7 +1,7 @@
mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
ArticleSchema = new mongoose.Schema(body: String, {strict:false, minimize: false})
ArticleSchema = new mongoose.Schema(body: String, {strict: false})
ArticleSchema.plugin(plugins.NamedPlugin)
ArticleSchema.plugin(plugins.VersionedPlugin)

View file

@ -1,7 +1,7 @@
mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
CampaignSchema = new mongoose.Schema(body: String, {strict:false, minimize: false})
CampaignSchema = new mongoose.Schema(body: String, {strict: false})
CampaignSchema.plugin(plugins.NamedPlugin)
CampaignSchema.plugin(plugins.TranslationCoveragePlugin)

View file

@ -4,7 +4,7 @@ jsonschema = require '../../app/schemas/models/level'
LevelSchema = new mongoose.Schema({
description: String
}, {strict:false, minimize: false})
}, {strict: false})
LevelSchema.plugin(plugins.NamedPlugin)
LevelSchema.plugin(plugins.PermissionsPlugin)

View file

@ -5,7 +5,7 @@ jsonschema = require '../../../app/schemas/models/level_component'
LevelComponentSchema = new mongoose.Schema {
description: String
system: String
}, {strict:false, minimize: false}
}, {strict: false}
LevelComponentSchema.plugin plugins.NamedPlugin
LevelComponentSchema.plugin plugins.PermissionsPlugin

View file

@ -8,6 +8,6 @@ LevelFeedbackSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
module.exports = LevelFeedback = mongoose.model('level.feedback', LevelFeedbackSchema)

View file

@ -10,7 +10,7 @@ LevelSessionSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
LevelSessionSchema.plugin(plugins.PermissionsPlugin)
LevelSessionSchema.plugin(AchievablePlugin)

View file

@ -4,7 +4,7 @@ jsonschema = require '../../../app/schemas/models/level_system'
LevelSystemSchema = new mongoose.Schema {
description: String
}, {strict:false, minimize: false}
}, {strict: false}
LevelSystemSchema.plugin(plugins.NamedPlugin)
LevelSystemSchema.plugin(plugins.PermissionsPlugin)

View file

@ -3,7 +3,7 @@ plugins = require '../../plugins/plugins'
ThangTypeSchema = new mongoose.Schema({
body: String,
}, {strict:false, minimize: false})
}, {strict: false})
ThangTypeSchema.plugin plugins.NamedPlugin
ThangTypeSchema.plugin plugins.VersionedPlugin

View file

@ -6,6 +6,6 @@ MailSent = new mongoose.Schema({
sent:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
module.exports = MailSent = mongoose.model('mail.sent', MailSent)

View file

@ -3,7 +3,7 @@ deltas = require '../../app/core/deltas'
log = require 'winston'
{handlers} = require '../commons/mapping'
PatchSchema = new mongoose.Schema({status: String}, {strict:false, minimize: false})
PatchSchema = new mongoose.Schema({status: String}, {strict: false})
PatchSchema.pre 'save', (next) ->
return next() unless @isNew # patch can't be altered after creation, so only need to check data once
@ -43,7 +43,7 @@ PatchSchema.pre 'save', (next) ->
patches = document.get('patches') or []
patches = _.clone patches
patches.push @_id
document.set 'patches', patches, {strict:false}
document.set 'patches', patches, {strict: false}
@targetLoaded = document
document.save (err) -> next(err)

View file

@ -1,6 +1,6 @@
mongoose = require('mongoose')
PaymentSchema = new mongoose.Schema({}, {strict:false, minimize: false})
PaymentSchema = new mongoose.Schema({}, {strict: false})
PaymentSchema.index({recipient: 1, 'stripe.timestamp': 1, 'ios.transactionID'}, {unique: true, name: 'unique payment'})
module.exports = mongoose.model('payment', PaymentSchema)

View file

@ -1,6 +1,6 @@
mongoose = require('mongoose')
PurchaseSchema = new mongoose.Schema({status: String}, {strict:false, minimize: false})
PurchaseSchema = new mongoose.Schema({status: String}, {strict: false})
PurchaseSchema.index({recipient: 1, 'purchased.original': 1}, {unique: true, name: 'unique purchase'})
module.exports = mongoose.model('purchase', PurchaseSchema)

View file

@ -5,6 +5,6 @@ UserCodeProblemSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
module.exports = UserCodeProblem = mongoose.model('user.code.problem', UserCodeProblemSchema)

View file

@ -17,7 +17,7 @@ UserSchema = new mongoose.Schema({
dateCreated:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
UserSchema.post('init', ->
@set('anonymous', false) if @get('email')

View file

@ -6,6 +6,6 @@ UserRemarkSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict:false, minimize: false})
}, {strict: false})
module.exports = UserRemark = mongoose.model('user.remark', UserRemarkSchema)

View file

@ -8,7 +8,7 @@ describe 'Level', ->
permissions: simplePermissions
scripts: []
thangs: []
documentation: {specificArticles: [{}], generalArticles: []}
documentation: {specificArticles: [], generalArticles: []}
urlLevel = '/db/level'