Commit 59d4c0c4 authored by Antony Orlovsky's avatar Antony Orlovsky

Updated test db model

parent dc22bb8d
......@@ -144,12 +144,16 @@ module.exports.update = (id, update) => {
return Test.findOneAndUpdate({_id: id}, update);
};
module.exports.getRemoved = task => {
module.exports.getRemovedForTask = task => {
return Test.find({task, status: defines.OBJECT_STATUS.REMOVED})
};
module.exports.getRemovedForContest = contest => {
return Test.find({contest, status: defines.OBJECT_STATUS.REMOVED})
};
module.exports.lockForTask = (task, reason) => {
return Test.findOneAndUpdate({task}, {
return Test.updateMany({task, status: defines.OBJECT_STATUS.ACTIVE}, {
status: defines.OBJECT_STATUS.LOCKED,
lock: {
reason,
......@@ -179,7 +183,7 @@ module.exports.erase = id => {
};
module.exports.addInputFile = (id, file) => {
return Test.updateMany({_id: id}, {$push: {inputFiles: file}});
return Test.findOneAndUpdate({_id: id}, {$push: {inputFiles: file}});
};
module.exports.addOutputFile = (id, fileName) => {
......@@ -187,11 +191,11 @@ module.exports.addOutputFile = (id, fileName) => {
};
module.exports.popInputFileManyForTask = task => {
return Test.findOneAndUpdate({task}, {$pop: {inputFiles: 1}});
return Test.updateMany({task}, {$pop: {inputFiles: 1}});
};
module.exports.popOutputFileManyForTask = task => {
return Test.findOneAndUpdate({task}, {$pop: {outputFiles: 1}});
return Test.updateMany({task}, {$pop: {outputFiles: 1}});
};
module.exports.setIndex = (id, index) => {
......
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