monkeytype/backend/dao/config.js

19 lines
513 B
JavaScript
Raw Normal View History

2021-06-08 23:02:44 +08:00
const MonkeyError = require("../handlers/error");
const { mongoDB } = require("../init/mongodb");
class ConfigDAO {
static async saveConfig(uid, config) {
return await mongoDB()
.collection("configs")
.updateOne({ uid }, { $set: { config } }, { upsert: true });
}
2021-07-06 21:51:43 +08:00
static async getConfig(uid) {
let config = await mongoDB().collection("configs").findOne({ uid });
// if (!config) throw new MonkeyError(404, "Config not found");
2021-07-06 21:51:43 +08:00
return config;
}
2021-06-08 23:02:44 +08:00
}
module.exports = ConfigDAO;