_doc property

1,039 views
Skip to first unread message

Davis Ford

unread,
May 9, 2012, 11:35:43 PM5/9/12
to mongoo...@googlegroups.com
Hi, I have a Schema defined in one module, and in another module, I modify the Schema and add mongoose-auth support to it.

When a user is returned from User.where('email', email).findOne( function (err, user) {

...the object structure looks like below.  I have to dig into the _doc property to get at the real model properties -- why is this?  I'm wondering if something is mis-configured b/c of the mongoose-auth manipulation.  The user docs indicate that _doc is an internal property not to be directly manipulated which leads me to believe something about what I am doing is wrong.

  1. _activePathsObject
  2. _docObject
  3. _eventsObject
  4. _maxListeners0
  5. _postsObject
  6. _presObject
  7. _saveErrornull
  8. _selectedundefined
  9. _shardvalundefined
  10. _strictModefalse
  11. _validationErrornull
  12. errorsundefined
  13. isNewfalse
  14. savefunction () { var self = this , hookArgs // arguments eventually passed to the hook - …
  15. __proto__Object

Aaron Heckmann

unread,
May 10, 2012, 10:30:50 AM5/10/12
to mongoo...@googlegroups.com
How are you logging the doc to see that? Using console.log should hide the internals. If not then yeah something is up.
--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en

Davis Ford

unread,
May 10, 2012, 10:51:58 AM5/10/12
to mongoo...@googlegroups.com
I was debugging with node-inspector after I tried to dereference a property that I expected to be there, and a null reference was encountered.

So, I fired up node-inspector and inspected it in the debugger.  If I do model.toObject() it converts it to an object with the properties, but then I lose all the model functionality (e.g. model.save( ) is no longer available).

See line 41/42 of this gist https://gist.github.com/2653658

I was expecting user to have .google property as it is added by the mongoose-auth plugin.  It is only available on user._doc.google

I think the problem might be on line 29 - perhaps I should be newing up a User instead returning the object that is created from the other module.export?

Aaron Heckmann

unread,
May 10, 2012, 12:16:42 PM5/10/12
to mongoo...@googlegroups.com
so it sounds like an issue with everyauth? from what i can tell mongoose auth should add .google.email etc to your schema.

Aaron Heckmann

unread,
May 10, 2012, 12:17:06 PM5/10/12
to mongoo...@googlegroups.com
may be an issue with mongoose-auth i mean. 
--
Aaron



Davis Ford

unread,
May 10, 2012, 12:31:27 PM5/10/12
to mongoo...@googlegroups.com
Well, the thing is, if I merge all this code into the same module, the problem goes away, so it has to be something about the way I have split it up and exported / imported it.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages