{"size": 1674, "ext": "js", "max_stars_repo_path": "models/event.js", "max_stars_repo_name": "rohitmaurya-png/inno", "max_stars_repo_stars_event_min_datetime": "2016-02-21T06:24:18.000Z", "max_stars_repo_stars_event_max_datetime": "2016-11-03T18:31:01.000Z", "max_issues_repo_path": "models/event.js", "max_issues_repo_name": "rohitmaurya-png/inno", "max_issues_repo_issues_event_min_datetime": "2020-10-13T12:01:09.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-24T17:08:43.000Z", "max_forks_repo_path": "models/event.js", "max_forks_repo_name": "rohitmaurya-png/inno", "max_forks_repo_forks_event_min_datetime": "2016-02-19T15:24:33.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-16T03:38:30.000Z"}
{"max_stars_count": 5, "max_issues_count": 11, "max_forks_count": 5, "avg_line_length": 29.3684210526, "max_line_length": 83, "alphanum_fraction": 0.56869773}
var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var Event = new Schema({
    name: {type:String, unique:true, dropDups:true, trim:true},
    linkName: {type:String, unique:true, dropDups:true, trim:true},
    shortDetails: String,
    details: {type:String, trim: true},
    fbLink: {type:String, trim: true},
    contact: String,
    timings: String,
    venue: String,
    photo: String,
    minParticipants: {type:Number, default:'1'},
    isTeamEvent: {type:Boolean,default:false},
    category: [String],
    managers: [{type: Schema.ObjectId, ref: 'Account'}],
    // In case of team events, participants and winners refer to team._id of teams
    participants: [{type: Schema.ObjectId}],
    winners: [{type: Schema.ObjectId}]
});

Event.methods.next = function(cb) {
    var model = this.model("Quote");
    model.findOne()
        .where('category').equals(this.category)
        .where('_id').gt(this._id).exec(function(err, event) {
        if (err) throw err;

        if (event) {
            cb(event);
        } else {
            // If quote is null, we've wrapped around.
            model.findOne(cb);
        }
    });
};

Event.methods.previous = function(cb) {
    var model = this.model("Quote");
    model.findOne()
        .where('category').equals(this.category)
        .where('_id').lt(this._id).exec(function(err, event) {
        if (err) throw err;

        if (event) {
            cb(event);
        } else {
            // If quote is null, we've wrapped around.
            model.findOne(cb);
        }
    });
};


module.exports = mongoose.model('Event', Event);
