add program Collection

parent 330729a4
/**
* Created by danilaeremin on 17.06.16.
*/
'use strict';
const dbUtils = require('db-utils');
module.exports = function (Program) {
return {
addProgram : function(name, owner, testProgramId) {
return dbUtils.dbCreateItem(Program,{ name: name, owner: owner, testProgramId: testProgramId});
},
getProgramById : function (programId) {
return dbUtils.dbFindOne(Program, {_id: programId}, [{ path: 'owner' }]);
},
getProgramsByOwner : function (ownerId) {
return dbUtils.dbFind(Program, {owner: ownerId}, [{ path: 'owner' }]);
},
removeProgramById : function (programId) {
return dbUtils.dbRemoveItem(Program, {_id: programId});
}
};
};
......@@ -19,6 +19,9 @@ module.exports = function (Task) {
},
removeTaskById : function (taskId) {
return dbUtils.dbRemoveItem(Task, {_id: taskId});
},
updateTaskMeta : function (taskId, meta) {
return dbUtils.dbFindOneAndUpdate(Task, {_id: taskId}, {meta : meta});
}
};
};
......@@ -21,7 +21,7 @@ module.exports = function (uri) {
return dbUtils.connect(uri)
.then(connection => {
let models = ['AccessToken','RefreshToken','User','Code','Client','Course', 'Contest', 'Task'];
let models = ['AccessToken','RefreshToken','User','Code','Client','Course', 'Contest', 'Task', 'Program'];
for (let i = 0; i < models.length; i++) {
let schema = require('./models/' + models[i]);
......
/**
* Created by danilaeremin on 07.09.16.
*/
const mongoose = require('mongoose');
var ProgramSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
owner: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true
},
testProgramId : {
type: mongoose.Schema.Types.ObjectId,
required: true
},
});
module.exports = ProgramSchema;
\ No newline at end of file
{
"name": "mirera-db",
"version": "1.2.0",
"version": "1.3.0",
"description": "DB utils for mirera program testing server",
"main": "index.js",
"scripts": {
......
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