import { db } from "../../../../database/dbclient.js";
import { rfidReaders } from "../../../../database/schema/rfidReaders.js";
import { returnRes } from "../../../globalUtils/routeDefs/returnRes.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";

export const getReaders = async () => {
    const { data, error } = await tryCatch(db.select().from(rfidReaders));

    if (error) {
        return returnRes(
            false,
            "There was an error getting the Readers",
            "rfid",
            "rfid",
            "error",
            error
        );
    }

    return returnRes(true, "Current readers", "rfid", "rfid", "info", data);
};
