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