import { db } from "../../../../../database/dbclient.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { printerData } from "../../../../../database/schema/printers.js";

export const getPrinters = async () => {
    const { data: printers, error: printerError } = await tryCatch(
        db.select().from(printerData).orderBy(printerData.name)
    );

    if (printerError) {
        return {
            success: false,
            message: "there was an error getting the printers",
            data: printerError,
        };
    }

    return { success: true, message: "Printers", data: printers };
};
