bnoguchi / mongoose-types

Additional handy types for mongoose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't access createdAt with Mongoose 2.3.2

alfrednerstu opened this issue · comments

I can't access createdAt. I can access and also see updatedAt when querying and looking at the collection
(I guess that createdAt uses the date in ObjectId and that's why I don't see it toghether with updatedAt in my collection?).

These are the packages I use:
mongodb@0.9.6-21
mongoose@2.3.2
mongoose-types@1.0.3

I had the same issue. I removed the if block in the plugin code to make this work. Can anyone shed light on why the plugin checks for the existence of _id path?

https://gist.github.com/1330798

The problem is with mongodb not exporting BinaryParser any more. You need to change the import in useTimestamps to something like this.

file ./lib/plugins/useTimestamps.js

var mongoose = require('mongoose')
, ObjectID = mongoose.ObjectID
, BinaryParser = require('mongoose/node_modules/mongodb/node_modules/bson').BinaryParser;