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

models/user.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 35
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
wmc 1
c 2
b 0
f 0
nc 2
mnd 0
bc 1
fnc 1
dl 0
loc 35
rs 10
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
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