mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
解离sandbox模块,完善迁移工具
This commit is contained in:
1 parent
42cbd020d5
commit
2d2b2930f0
6 files changed
+106
-77
No files matched your search
@@ -8,6 +8,7 @@ const db = require('../service/db.js');
|
||||
const coll = db.collection('discussion');
|
||||
const collReply = db.collection('discussion.reply');
|
||||
const collStatus = db.collection('discussion.status');
|
||||
const collNode = db.collection('discussion.node');
|
||||
|
||||
async function add(parentType, parentId, owner, title, content, ip = null, highlight = false) {
|
||||
const res = await coll.insertOne({
|
||||
@@ -132,6 +133,10 @@ function getStatus(did, uid) {
|
||||
return collStatus.findOne({ did, uid });
|
||||
}
|
||||
|
||||
function getNode(_id) {
|
||||
return collNode.findOne({ _id });
|
||||
}
|
||||
|
||||
async function getVnode(ddoc, handler) {
|
||||
if (ddoc.parentType === 'problem') {
|
||||
const pdoc = await problem.getById(ddoc.parentId);
|
||||
@@ -141,7 +146,11 @@ async function getVnode(ddoc, handler) {
|
||||
} if (ddoc.parentType === 'contest') {
|
||||
const tdoc = await contest.get(ddoc.parentId);
|
||||
return { ...tdoc, parentType: ddoc.parentType, parentId: ddoc.parentId };
|
||||
} return null;
|
||||
} if (ddoc.parentType === 'node') {
|
||||
const ndoc = await getNode(ddoc.parentId);
|
||||
return { ...ndoc, parentType: ddoc.parentType, parentId: ddoc.parentId };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function getListVnodes(ddocs, handler) {
|
||||
|
||||
Reference in new issue
Block a user