news-analyze/server/scrape/save_scrape_data.ts
吳元皓 8975812447 Make the news View working via the tty interface, and made some more
i18n stuff & update some more to add images and unknown data oh, also
paragraphs are now a thing :) and do so much debugging.
2025-05-18 13:12:39 +08:00

21 lines
532 B
TypeScript

import postgres from "~/server/components/postgres";
import { v4 as uuidv4 } from "uuid";
async function saveDataToSql(
data: {
title: string;
paragraph: any;
author: string;
origin: string;
image: any;
},
slug: string,
) {
const sql = postgres;
await sql`
INSERT INTO articles_lt (uuid, slug, title, content, author, origin)
VALUES (${uuidv4()}, ${slug}, ${data.title}, ${data.paragraph}, ${data.author}, ${data.origin})
ON CONFLICT (slug) DO NOTHING
`;
}
export default saveDataToSql;