tblobaum / mongoose-troop

plugins for your mongoose schemas.
MIT License
242 stars 29 forks source link

created field is not created #17

Closed panosru closed 12 years ago

panosru commented 12 years ago

Hello I try to use the timestamp plugin but only modified field is created the created time field is not... any idea?

panosru commented 12 years ago

Ok, as I saw it uses a useVirtual option in order to provide the created time based from _id but how I can I access that?

panosru commented 12 years ago

ok nvm I did a horible mistake :P

I was passing the document through json and then I tried to access the virtual field from the json object, which obvisly faild :P

tblobaum commented 12 years ago

@panosru you can pass virtuals in mongoose (such as the created) with doc.toObject({ /* getters: true, */ virtuals: true }) and then stringify the object or you can change the timestamp plugin so it doesn't use virtuals with mySchema.plugin(troop.timestamp, { useVirtual: false }) -- but with this second option you'll be storing the created time data twice when you dont need to.

panosru commented 12 years ago

@tblobaum oh I didn't knew about this! Thanks a lot! :) :)