Skip to content

Commit 2807e70

Browse files
harkirat singhharkirat singh
authored andcommitted
Added week 10 assignments
1 parent 05eff6f commit 2807e70

File tree

16 files changed

+7040
-7
lines changed

16 files changed

+7040
-7
lines changed

week-10/1-postgres-simple/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,25 @@ and put it in config.ts
1313
You are supposed to write the `database` part of an full stack app.
1414
Specifically, you need to fill the functions in
1515
- src/db/user.ts
16-
- src/db/todo.ts
16+
- src/db/todo.ts
17+
18+
## Testing
19+
Run `npm run test` to run all the tests
20+
21+
## Call out
22+
The schema of the tables looks like this -
23+
```
24+
CREATE TABLE IF NOT EXISTS users (
25+
id SERIAL PRIMARY KEY,
26+
username VARCHAR(255) UNIQUE NOT NULL,
27+
password VARCHAR(255) NOT NULL,
28+
name VARCHAR(255) NOT NULL
29+
);
30+
CREATE TABLE IF NOT EXISTS todos (
31+
id SERIAL PRIMARY KEY,
32+
user_id INTEGER NOT NULL REFERENCES users(id),
33+
title VARCHAR(255) NOT NULL,
34+
description TEXT,
35+
done BOOLEAN DEFAULT false
36+
);
37+
```

week-10/1-postgres-simple/src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@ import { DB_URL } from './config';
44
export const client = new Client({
55
connectionString: DB_URL
66
});
7-
8-
function seed() {
9-
10-
}
11-
12-
seed();

week-10/2-prisma-simple/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
# Keep environment variables out of version control
3+
.env

week-10/2-prisma-simple/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Prisma Assignment
2+
Same as the last assignment, but you need to use `prisma` as the ORM.
3+
4+
## Pre-requisites
5+
1. Checkout `prisma/schema.prisma` and see the initial schema that has been created.
6+
2. Replace `db.url` with your database URL.
7+
3. Run the following commands to migrate your database -
8+
```js
9+
npx prisma migrate dev
10+
npx prisma generate
11+
```
12+
13+
## Assignment
14+
You need to fill the db/user.ts and db/todos.ts using the `prisma` client to put in the data
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// jest.config.js
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
// Optionally, set up paths to match your project structure
6+
roots: ['<rootDir>/src'],
7+
// Transform settings if you have custom needs, but this is optional since ts-jest is preset
8+
transform: {
9+
'^.+\\.ts$': 'ts-jest',
10+
},
11+
// Module file extensions for importing
12+
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
13+
};
14+

0 commit comments

Comments
 (0)