add mongo

This commit is contained in:
Sebastian Seedorf
2022-08-17 09:09:49 +02:00
parent 1522962edd
commit fe7e6d8ae2
10 changed files with 326 additions and 2 deletions

19
src/database/groups.ts Normal file
View File

@@ -0,0 +1,19 @@
import {database} from "./start";
import {Dict, Group} from "../types";
import crypto from "crypto"
export async function setGroups(groups: Dict<Group>, ignored: string[], base: string[]) {
const collection = (await database.resolve())?.collection('setups')
if (!collection) return
await collection.deleteMany({}).catch(e => {
if (e.message !== 'ns not found') throw e
})
const result = await collection.insertOne({
groups,
ignored,
base,
createdOn: new Date(),
modifiedOn: new Date()
})
return result.insertedId.toString()
}