云剪贴板

This commit is contained in:
undefined committed 2020-05-03 18:23:58 +08:00
1 parent 474f495e0c
commit 00cd747768
5 files changed
+174

No files matched your search

+26
View File
@@ -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 };