Completed
Push — master ( adb79c...2d8abe )
by Neil
01:28
created

userSchema.statics.load   A

Complexity

Conditions 1
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 2
dl 0
loc 6
rs 9.4285
nop 2
1
// The User model
2
3
var mongoose = require('mongoose')
4
var Schema = mongoose.Schema
5
6
var userSchema = new Schema({
7
  name: { type: String, default: '' },
8
  email: { type: String, default: '' },
9
  username: { type: String, default: '' },
10
  provider: { type: String, default: '' },
11
  hashed_password: { type: String, default: '' },
12
  salt: { type: String, default: '' },
13
  authToken: { type: String, default: '' },
14
  google: {},
15
  isAdmin: Boolean
16
})
17
18
19
userSchema.statics = {
20
21
  /**
22
   * Load
23
   *
24
   * @param {Object} options
25
   * @param {Function} cb
26
   * @api private
27
   */
28
29
  load: function (options, cb) {
30
    options.select = options.select || 'name username'
31
    return this.findOne(options.criteria)
32
      .select(options.select)
33
      .exec(cb)
34
  }
35
}
36
37
module.exports = mongoose.model('User', userSchema)
38