1.0.0-preview

This commit is contained in:
masnn committed 2020-05-13 12:25:18 +08:00
1 parent 90b06d6aa7
commit 8cd84f29e8
18 files changed
+152 -401

No files matched your search

+8 -1
View File
@@ -160,7 +160,13 @@ async function setTestdata(_id, readStream) {
return await edit(_id, { data: f.id }); // eslint-disable-line no-return-await
}
module.exports = {
async function getData(pid) {
const pdoc = await get(pid);
if (!pdoc.data) return null;
return gridfs.openDownloadStream(pdoc.data);
}
global.Hydro.model.problem = module.exports = {
add,
inc,
get,
@@ -175,4 +181,5 @@ module.exports = {
getMultiStatus,
setTestdata,
updateStatus,
getData,
};
+2 -2
View File
@@ -21,7 +21,7 @@ function del(_id) {
async function getFirst(query) {
const res = await coll.find(query).sort('_id', 1).limit(1).toArray();
if (res) {
if (res.length) {
await coll.deleteOne({ _id: res[0]._id });
return res[0];
}
@@ -35,6 +35,6 @@ async function consume(query, cb) {
}, 100);
}
module.exports = {
global.Hydro.model.task = module.exports = {
add, get, del, count, getFirst, consume,
};