import { ObjectId } from "mongodb";
import { Sectors } from "./mongodb";
import DBSector from "../../types/db/DBSector";

export const getAllSectors = async () => {
    return await (await Sectors()).find({}).toArray() as DBSector[];
}

export const getSectorById = async (id: ObjectId) => {
    return await (await Sectors()).findOne({
        _id: id
    }) as DBSector;
}

export const addSystemToSector = async (sectorId: ObjectId, systemId: ObjectId) => {
    return await (await Sectors()).updateOne({ _id: sectorId }, { $push: { systems: systemId } });
}