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 description: { type: String },
23 img: { type: String, default: "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" },
24 contact: {
25 twitter: { type: String },
26 facebook: { type: String },
27 telegram: { type: String },
28 web: { type: String },
29 phone: { type: Number }
30 },
31 location:{
32 direction: { type: String },
33 city: { type: String },
34 district: { type: String },
35 geo: {
36 lat: {type: Number},
37 long: {type: Number},
38 name: { type: String}
39 }
40 },
41 events: [{
42 type: mongoose.Schema.Types.ObjectId,
43 ref: 'eventModel'
44 }]
45});
46
47userSchema.plugin(mongooseUniqueValidator);
48module.exports = mongoose.model('userModel', userSchema);