add mongo
This commit is contained in:
19
src/database/groups.ts
Normal file
19
src/database/groups.ts
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user