Add contest table

parent df1fb485
/**
* Created by danilaeremin on 17.06.16.
*/
'use strict';
const dbUtils = require('db-utils');
module.exports = function (Contest) {
return {
addContest : function(courseId, type, name, info, description, start, finish, meta) {
return dbUtils.dbCreateItem(Contest,{ course: courseId, type: type, name: name, info: info, description: description, start : start, finish : finish, meta : meta});
},
getContestById : function (contestId) {
return dbUtils.dbFindOne(Contest, {_id: contestId}, [{ path: 'course' }]);
},
getContestByCourse : function (courseId) {
return dbUtils.dbFind(Contest, {course: courseId}, [{ path: 'course' }]);
},
removeContestById : function (contestId) {
return dbUtils.dbRemoveItem(Contest, {_id: contestId});
}
};
};
......@@ -21,4 +21,4 @@ module.exports = function (Course) {
return dbUtils.dbRemoveItem(Course, {_id: courseId});
}
};
}
};
/**
* Created by danilaeremin on 29.08.16.
*/
var mongoose = require('mongoose');
var ContestSchema = new mongoose.Schema({
course: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Contest',
required: true
},
type: {
type: String,
default: '',
required: true
},
name: {
type: String,
default: '',
required: true
},
info: {
type: String,
default: '',
required: true
},
description: {
type: String,
default: '',
required: true
},
created: {
type: Date,
default: Date.now,
required: true,
},
start: {
type: Date,
default: Date.now,
required: true,
},
finish: {
type: Date,
default: Date.now,
required: true,
},
meta: {
type: {},
required: true,
default: {}
}
});
module.exports = ContestSchema;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment