mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
// @ts-check
|
|
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
|
|
export const precios = sqliteTable(
|
|
"precios",
|
|
{
|
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
ean: text("ean").notNull(),
|
|
fetchedAt: integer("fetched_at", { mode: "timestamp" }).notNull(),
|
|
precioCentavos: integer("precio_centavos"),
|
|
inStock: integer("in_stock", { mode: "boolean" }),
|
|
url: text("url").notNull(),
|
|
warcRecordId: text("warc_record_id"),
|
|
parserVersion: integer("parser_version"),
|
|
name: text("name"),
|
|
imageUrl: text("image_url"),
|
|
},
|
|
(precios) => {
|
|
return {
|
|
preciosEanIdx: index("precios_ean_idx").on(precios.ean),
|
|
preciosUrlIdx: index("precios_url_idx").on(precios.url),
|
|
preciosFetchedAtIdx: index("precios_fetched_at_idx").on(
|
|
precios.fetchedAt
|
|
),
|
|
};
|
|
}
|
|
);
|
|
|
|
/** @typedef {typeof precios.$inferSelect} Precio */
|
|
|
|
export const productoUrls = sqliteTable("producto_urls", {
|
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
url: text("url").unique().notNull(),
|
|
firstSeen: integer("first_seen", { mode: "timestamp" }).notNull(),
|
|
lastSeen: integer("last_seen", { mode: "timestamp" }).notNull(),
|
|
});
|
|
|
|
/** @typedef {typeof productoUrls.$inferSelect} ProductUrl */
|
|
|
|
export const bestSelling = sqliteTable("db_best_selling", {
|
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
fetchedAt: integer("fetched_at", { mode: "timestamp" }).notNull(),
|
|
category: text("category").notNull(),
|
|
eansJson: text("eans_json").notNull(),
|
|
});
|
|
|
|
/** @typedef {typeof bestSelling.$inferSelect} BestSelling */
|