mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-28 00:35:25 +08:00
* converted preset dao to dal * psa dao > dal * typo * config dao > dal * public stats dao > dal * fixed bad merge * removed this * removed comment
18 lines
536 B
TypeScript
18 lines
536 B
TypeScript
import { UpdateResult } from "mongodb";
|
|
import db from "../init/db";
|
|
import _ from "lodash";
|
|
|
|
export async function saveConfig(
|
|
uid: string,
|
|
config: object
|
|
): Promise<UpdateResult> {
|
|
const configChanges = _.mapKeys(config, (_value, key) => `config.${key}`);
|
|
return await db
|
|
.collection<any>("configs")
|
|
.updateOne({ uid }, { $set: configChanges }, { upsert: true });
|
|
}
|
|
|
|
export async function getConfig(uid: string): Promise<any> {
|
|
const config = await db.collection<any>("configs").findOne({ uid });
|
|
return config;
|
|
}
|