feat: Refactor database initialization and table creation
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
// import index from '$lib/index';
|
||||
import type { Content } from '$lib/article';
|
||||
import { pool } from '$lib/server/database';
|
||||
import PG from '$lib/server/database';
|
||||
|
||||
let data: {
|
||||
recent: Content[],
|
||||
@@ -23,16 +22,11 @@ let data: {
|
||||
};
|
||||
|
||||
export const load: PageServerLoad = async ({ params }) => {
|
||||
const connect = await pool.connect();
|
||||
const result = await connect.query('SELECT NOW()')
|
||||
.then((res) => {
|
||||
data.updated = res.rows[0].now.toISOString();
|
||||
})
|
||||
.catch((err) => {
|
||||
error(err);
|
||||
});
|
||||
connect.release();
|
||||
const db = await PG();
|
||||
const now = await db.query('SELECT NOW()');
|
||||
await db.release();
|
||||
|
||||
data.updated = now.rows[0].now;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user