Monthly Archives: April 2015

Mongoose: Cannot read property ‘paths’ of undefined

When working with Mongoose, make sure you never ever name a property “type”, since it’s reserved for declaring datatypes on fields. Take a look at this:

permissions: {
  type: String,   // this will throw an error
  userGroups: [
    {
      group: { type: mongoose.Schema.Types.ObjectId, ref: 'UserGroups' },   // correct use of "type"
      permission: String
    }
  ]
}

This will throw an uncaught exception. I’m writing this post so I can save you 20 minutes of debugging. Here’s the correct approach:

permissions: {
  permissionType: String,   // correct usage
  userGroups: [
    {
      group: { type: mongoose.Schema.Types.ObjectId, ref: 'UserGroups' },
      permission: String 
    }
  ]
}

 

Smoother/Faster CSS Animations

If you have ever experienced slow/”buffering” CSS animations then it’s probably because you don’t know about this article. Basically, instead of animating¬†the position properties “top”, “right”, “bottom” and “left”, you animate “transform: translate”.¬†On most browsers this activates hardware acceleration, meaning it will use the computers graphic chip instead of the CPU and will therefore produce smoother animations.