From f866380707dee6d9240adebc60e8464c8f7b58b5 Mon Sep 17 00:00:00 2001 From: Sliverkiss <1393579810@qq.com> Date: Sat, 11 Oct 2025 16:12:07 +0800 Subject: [PATCH] Create MongoDB.min.js --- Utils/MongoDB.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 Utils/MongoDB.min.js diff --git a/Utils/MongoDB.min.js b/Utils/MongoDB.min.js new file mode 100644 index 0000000..ccacb89 --- /dev/null +++ b/Utils/MongoDB.min.js @@ -0,0 +1 @@ +function MongoDB(t, n, o, e, s) { return new class { constructor(t, n, o, e, s) { this.BASE_URL = t, this.username = n, this.password = o, this.database = e, this.collection = s } async commonPost(t) { const { url: n, headers: o, body: e, method: s = "post" } = t, a = { url: `${this.BASE_URL}${n}`, headers: { "Content-Type": "application/json", Accept: "application/json", ...o }, body: $.toStr({ USERNAME: this.username, PASSWORD: this.password, DATABASE: this.database, COLLECTION: this.collection, ...e }) }; return $.info($.toStr(a.body)), new Promise((t => { $[s](a, ((n, o, e) => { let s = $.toObj(e) || e; t(s) })) })) } async findOne(t) { const n = { url: "/findOne", body: { filter: t } }; return await this.commonPost(n) } async find(t) { const n = { url: "/find", body: { filter: t } }; return await this.commonPost(n) } async insertOne(t) { const n = { url: "/insertOne", body: { document: t } }; return await this.commonPost(n) } async insertMany(t) { const n = { url: "/insertMany", body: { documents: t } }; return await this.commonPost(n) } async updateOne(t, n) { const o = { url: "/updateOne", body: { filter: t, update: n } }; return await this.commonPost(o) } async updateMany(t, n) { const o = { url: "/updateMany", body: { filter: t, update: n } }; return await this.commonPost(o) } async deleteOne(t) { const n = { url: "/deleteOne", body: { filter: t } }; return await this.commonPost(n) } async deleteMany(t) { const n = { url: "/deleteMany", body: { filter: t } }; return await this.commonPost(n) } }(t, n, o, e, s) }