Artyom Trityak
Artyom Trityak

Reputation: 647

Node.js Mongoose: Include excluded fields

I have schema

var UserSchema = new Schema({
  salt: {
    type: String,
    select: false
  },
  facebook: {},
  google: {}
});

Question. I've set salt default excluded, how to include it in response? If i would set this.findOne({}, 'salt') it will return ONLY salt.

Upvotes: 1

Views: 517

Answers (1)

JohnnyHK
JohnnyHK

Reputation: 312149

Use '+salt' to override the default without excluding other fields:

this.findOne({}, '+salt')

Docs here.

Upvotes: 3

Related Questions