mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
云剪贴板
This commit is contained in:
1 parent
474f495e0c
commit
00cd747768
5 files changed
+174
No files matched your search
@@ -0,0 +1,26 @@
|
||||
const { DocumentNotFoundError } = global.Hydro.error;
|
||||
const { db } = global.Hydro.service;
|
||||
|
||||
const coll = db.collection('pastebin');
|
||||
|
||||
async 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;
|
||||
}
|
||||
|
||||
async function get(_id) {
|
||||
const doc = await coll.findOne({ _id });
|
||||
if (!doc) throw new DocumentNotFoundError(_id);
|
||||
return doc;
|
||||
}
|
||||
|
||||
function del(_id) {
|
||||
return coll.deleteOne({ _id });
|
||||
}
|
||||
|
||||
global.Hydro.model.pastebin = module.exports = { add, get, del };
|
||||
Reference in new issue
Block a user