import { desc, lte, sql } from "drizzle-orm"; import { Router } from "express"; import { open } from "inspector/promises"; import { db } from "../db/db.controller.js"; import { opendockApt } from "../db/schema/opendock.schema.js"; import { apiReturn } from "../utils/returnHelper.utils.js"; import { tryCatch } from "../utils/trycatch.utils.js"; const r = Router(); r.get("/", async (_, res) => { //const limit const { data, error } = await tryCatch( db .select() .from(opendockApt) .where(lte(opendockApt.createdAt, sql.raw(`NOW() - INTERVAL '30 days'`))) .orderBy(desc(opendockApt.createdAt)) .limit(500), ); apiReturn(res, { success: true, level: "info", module: "opendock", subModule: "apt", message: "The first x Apt", data: data ?? [], status: 200, }); }); export default r;