models/user.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 34
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
c 2
b 0
f 0
nc 2
dl 0
loc 34
rs 10
wmc 1
mnd 0
bc 1
fnc 1
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A userSchema.statics.load 0 6 1
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
userSchema.statics = {
19
20
  /**
21
   * Load
22
   *
23
   * @param {Object} options
24
   * @param {Function} cb
25
   * @api private
26
   */
27
28
  load: function (options, cb) {
29
    options.select = options.select || 'name username'
30
    return this.findOne(options.criteria)
31
      .select(options.select)
32
      .exec(cb)
33
  }
34
}
35
36
module.exports = mongoose.model('User', userSchema)
37