mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
拆分域管理与系统管理
This commit is contained in:
1 parent
385e46ae42
commit
faec4744d7
24 files changed
+249
-168
No files matched your search
@@ -1,26 +1,27 @@
|
||||
const { DocumentNotFoundError } = global.Hydro.error;
|
||||
const { db } = global.Hydro.service;
|
||||
const { document } = global.Hydro.model;
|
||||
|
||||
const coll = db.collection('pastebin');
|
||||
document.TYPE_PASTE = 101;
|
||||
|
||||
async function add({
|
||||
function add({
|
||||
owner, language, expire, password, title, content,
|
||||
}) {
|
||||
const doc = {
|
||||
owner, password, expire, language, title, content,
|
||||
};
|
||||
const res = await coll.insertOne(doc);
|
||||
return res.insertedId;
|
||||
return document.add(
|
||||
'system', content, owner, document.TYPE_PASTE, null, null, null,
|
||||
{
|
||||
language, expire, title, password,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function get(_id) {
|
||||
const doc = await coll.findOne({ _id });
|
||||
const doc = await document.get('system', document.TYPE_PASTE, _id);
|
||||
if (!doc) throw new DocumentNotFoundError(_id);
|
||||
return doc;
|
||||
}
|
||||
|
||||
function del(_id) {
|
||||
return coll.deleteOne({ _id });
|
||||
return document.deleteOne('system', document.TYPE_PASTE, _id);
|
||||
}
|
||||
|
||||
global.Hydro.model.pastebin = module.exports = { add, get, del };
|
||||
Reference in new issue
Block a user