diff options
author | Vitaly Takmazov | 2024-10-11 03:45:56 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-10-11 03:45:56 +0300 |
commit | 5ab2f6aa9ae409e485d9106e8bff411c30602462 (patch) | |
tree | 43e52df90e03af44667f1611cdeb10a6e9edec94 /vnext/server/db | |
parent | bbdab5e2d38da2dfd7fea2f7a3593819cad21faa (diff) |
vnext: initial database connection
Diffstat (limited to 'vnext/server/db')
-rw-r--r-- | vnext/server/db/index.js | 5 | ||||
-rw-r--r-- | vnext/server/db/users.js | 14 |
2 files changed, 19 insertions, 0 deletions
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 +} |