drudge / mongoose-timestamp

Adds createdAt and updatedAt date attributes that get auto-assigned to the most recent create/update timestamp
Other
308 stars 64 forks source link

When used with passport-local-mongoose and mongoDB 3.0 we get this issue #29

Open BrandonCopley opened 9 years ago

BrandonCopley commented 9 years ago

[TypeError: Cannot assign to read only property 'checkKeys' of true]

passport-local-mongoose 1.0.1 timestamps 0.4.0

var mongoose = require('mongoose');
var passportLocalMongoose = require('passport-local-mongoose');
var timestamps = require('mongoose-timestamp');

var Schema = mongoose.Schema;

exports.User = mongoose.model('User', new Schema({
  username: {
    type: String,
    index: {
      unique: true,
      sparse: true
    }
  },
  email: String
}, {
  safe: true,
  strict: true
}).plugin(passportLocalMongoose, {}).plugin(timestamps));

removing the timestamps plugin gets this working, but I liked the timestamps plugin.

BrandonCopley commented 9 years ago

I've narrowed this down to something with strict:true turned on causing issues in other code of mine, is this perhaps being used here?