src/models/user.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 31
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
wmc 1
c 1
b 0
f 0
nc 2
mnd 1
bc 2
fnc 0
dl 0
loc 31
rs 10
bpm 0
cpm 0
noi 0
1
'use strict'
2
3
import mongoose from 'mongoose'
4
import timestamps from 'mongoose-timestamp'
5
import devise from 'node-devise'
6
import mailer from '../mailers'
7
import i18n from '../helpers/i18n'
8
9
const userSchema = new mongoose.Schema({
10
  account: {
11
    language: {
12
      type: String,
13
      default: 'en-US'
14
    }
15
  }
16
})
17
userSchema.plugin(timestamps)
18
userSchema.plugin(devise, { i18n })
19
userSchema.plugin(mailer, { i18n })
20
21
// https://github.com/Automattic/mongoose/issues/1251
22
let instance
23
24
try {
25
  // http://mongoosejs.com/docs/api.html#index_Mongoose-model
26
  instance = mongoose.model('User', userSchema, 'users')
27
} catch (error) {
28
  instance = mongoose.model('User')
29
}
30
31
module.exports.User = instance
32