From 5ab2f6aa9ae409e485d9106e8bff411c30602462 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 11 Oct 2024 03:45:56 +0300 Subject: vnext: initial database connection --- vnext/server/db/index.js | 5 +++++ vnext/server/db/users.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 vnext/server/db/index.js create mode 100644 vnext/server/db/users.js (limited to 'vnext/server/db') diff --git a/vnext/server/db/index.js b/vnext/server/db/index.js new file mode 100644 index 00000000..7a029627 --- /dev/null +++ b/vnext/server/db/index.js @@ -0,0 +1,5 @@ +import postgres from 'postgres' + +const sql = postgres({ database: 'juick', host: process.env.PG_HOST }) + +export default sql diff --git a/vnext/server/db/users.js b/vnext/server/db/users.js new file mode 100644 index 00000000..2201b1ef --- /dev/null +++ b/vnext/server/db/users.js @@ -0,0 +1,14 @@ +import sql from './index' + +/** + * Count users + */ +export async function get_count() { + const count = await sql` + select + count(*) + from users + where banned=0 + ` + return count +} -- cgit v1.2.3