Skip to content

Commit

Permalink
week10 re-added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainith123 committed Mar 3, 2024
1 parent cbab013 commit 4429657
Show file tree
Hide file tree
Showing 27 changed files with 13,595 additions and 0 deletions.
1 change: 1 addition & 0 deletions week-10/1-postgres-simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
37 changes: 37 additions & 0 deletions week-10/1-postgres-simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Simple SQL queries practise.

In this assignment, you'll be writing a bunch of SQL queries to interact with your postgres database.

## Pre-requisites
Before you start, please grab a Postgres URL from either of the following -
- https://neon.tech/
- https://aiven.io/

and put it in config.ts

## Assignment
You are supposed to write the `database` part of an full stack app.
Specifically, you need to fill the functions in
- src/db/user.ts
- src/db/todo.ts

## Testing
Run `npm run test` to run all the tests

## Call out
The schema of the tables looks like this -
```
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS todos (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
title VARCHAR(255) NOT NULL,
description TEXT,
done BOOLEAN DEFAULT false
);
```
14 changes: 14 additions & 0 deletions week-10/1-postgres-simple/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// jest.config.js
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
// Optionally, set up paths to match your project structure
roots: ['<rootDir>/src'],
// Transform settings if you have custom needs, but this is optional since ts-jest is preset
transform: {
'^.+\\.ts$': 'ts-jest',
},
// Module file extensions for importing
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};

Loading

0 comments on commit 4429657

Please sign in to comment.