arnaucube
arnaucube/openEventsPlatformServerPublic Self-hosted repository
openEventsPlatformServer/models/userModel.js
models/userModel.jsRaw
 1var mongoose = require('mongoose'),
 2    Schema   = mongoose.Schema;
 3
 4var mongooseUniqueValidator = require('mongoose-unique-validator');
 5
 6var userSchema = new Schema({
 7    username: { type: String, required: true, unique: true },
 8    email:   { type: String, required: true },
 9    password: { type: String, required: true, select: false },
10    tokens: [{
11        userAgent: {type: String, select: false},
12        token: {type: String, select: false},
13        os: {type: String, select: false},
14        browser: {type: String, select: false},
15        device: {type: String, select: false},
16        os_version: {type: String, select: false},
17        browser_version: {type: String, select: false},
18        ip: {type: String, select: false},
19        lastLogin: {type: Date, select: false},
20        birthdate: {type: Date, select: false},
21    }],
22    shortDescription:   { type: String },
23    description:   { type: String },
24    img:   { type: String, default: "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" },
25    contact: {
26        twitter:   { type: String },
27        facebook:   { type: String },
28        telegram:   { type: String },
29        web:   { type: String },
30        phone: { type: Number }
31    },
32    location:{
33        direction: { type: String },
34        city:   { type: String },
35        district: { type: String },
36        geo: {
37            lat: {type: Number},
38            long: {type: Number},
39            name: { type: String}
40        }
41    },
42    events: [{
43        type: mongoose.Schema.Types.ObjectId,
44        ref: 'eventModel'
45    }]
46});
47
48userSchema.plugin(mongooseUniqueValidator);
49module.exports = mongoose.model('userModel', userSchema);