arnaucube
arnaucube/openEventsPlatformServerPublic Self-hosted repository
openEventsPlatformServer/models/eventModel.js
models/eventModel.jsRaw
 1var mongoose = require('mongoose'),
 2    Schema   = mongoose.Schema;
 3
 4var mongooseUniqueValidator = require('mongoose-unique-validator');
 5
 6var eventSchema = new Schema({
 7    title: { type: String },
 8    description:   { type: String },
 9    img:   { type: String },
10    date: { type: Date },
11    categories: [{
12        name: {type: String}
13    }],
14    location: {
15        direction: { type: String },
16        city:   { type: String },
17        district: { type: String },
18        geolocation: {
19            lat: {type: Number},
20            long: {type: Number},
21            name: { type: String, required: true }
22        }
23    },
24    user: {
25        type: mongoose.Schema.Types.ObjectId,
26        ref: 'userModel'
27    }
28});
29
30eventSchema.plugin(mongooseUniqueValidator);
31module.exports = mongoose.model('eventModel', eventSchema);