mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 08:16:20 +08:00
19 lines
510 B
TypeScript
19 lines
510 B
TypeScript
import { UpdateResult } from "mongodb";
|
|
import db from "../init/db";
|
|
|
|
class ConfigDAO {
|
|
static async saveConfig(uid, config): Promise<UpdateResult> {
|
|
return await db
|
|
.collection("configs")
|
|
.updateOne({ uid }, { $set: { config } }, { upsert: true });
|
|
}
|
|
|
|
static async getConfig(uid): Promise<object> {
|
|
const config = await db.collection("configs").findOne({ uid });
|
|
// if (!config) throw new MonkeyError(404, "Config not found");
|
|
return config;
|
|
}
|
|
}
|
|
|
|
export default ConfigDAO;
|