I've got an app that uses an older version of mongoose.js, and I've been in the process of upgrading it to 2.9.x (with the intention of upgrading to 3.x after this update is successful). It seems to (mostly) work alright, up until I try to set anything which has a schema type of Mixed. When I do this it errors out saying TypeError: Cannot read property 'name' of undefined.
Here's my schema:
mongoose = require 'mongoose'
Schema = mongoose.Schema
Mixed = Schema.Types.Mixed
LogItemSchema = new Schema({
action: String
, user: String
, comment: String
, time: Date
, modal: Mixed
})
module.exports = LogItem = mongoose.model('LogItem', LogItemSchema)
I can create a new LogItem fine, up until I attempt to set the modal property (generally with a semi-complex object, ie. {type: 'string', companies: ['company1', 'company2']}), it will error out.
If I don't set modal, there are no errors. Any idea why this would be?
Moral of the story: don't used Mixed types.
But seriously, I never did figure out what this particular issue was. I ended up just updating to the latest version of Mongoose and dealt with the errors as they came in (mostly API changes).
The logs were changed before that to not include any Mixed data.