AstroCol/src/lib/db/systems.ts

22 lines
640 B
TypeScript

import { ObjectId } from "mongodb";
import { Systems } from "./mongodb";
import DBSystem from "../../types/db/DBSystem";
export const getAllSystems = async () => {
return await (await Systems()).find({}).toArray() as DBSystem[];
}
export const getSystemById = async (id: ObjectId) => {
return await (await Systems()).findOne({
_id: id
}) as DBSystem;
}
export const updateSystemStructures = async (systemId: ObjectId, structures: Array<{ id: string, level: number }>) => {
const systems = await Systems();
await systems.updateOne({ _id: systemId }, {
$set: {
structures
}
});
}