| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 34 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | // The User model |
||
| 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 |