davidesp
davidesp

Reputation: 3962

UserModel.findOne returns an object with members duplicated inside member: _doc

I'm using Node, Passport, LocalStrategy, Mongoose for one simple project, and have 2 questions...

  1. why the user element returned by UserModel.findOne(...) has the members I expect it has: { _id, local, facebook, google, twitter, createdAt, updatedAt }, but all these members are also (duplicated) inside its member: _doc?

enter image description here

when I expand the _doc member, I get:

enter image description here

  1. what's the type of the variable: user?

Could you clarify these 2 questions for me?

Thanks!

Upvotes: 1

Views: 401

Answers (1)

Dushyant Bangal
Dushyant Bangal

Reputation: 6403

_doc is the raw js object.
user is the mongoose Document, that inherits javascript Object.

Mongoose provides a lot of different APIs, that are included in the Document object.

While _doc will just have the APIs that a normal javascript object offers.

Upvotes: 1

Related Questions