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