Skip to content

Commit 79167e6

Browse files
committed
Update readme backend
1 parent c4d25d5 commit 79167e6

File tree

1 file changed

+183
-64
lines changed

1 file changed

+183
-64
lines changed

backend/README.md

Lines changed: 183 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,27 @@ $ pnpm run test:cov
3737
Use Prisma CLI to apply migrations and generate the Prisma client:
3838

3939
```bash
40-
npx prisma migrate dev
41-
npx prisma generate
40+
$ npx prisma migrate dev
41+
$ npx prisma generate
4242
```
4343

4444
### Seed the Cafes and Employees (add dummy data)
4545

4646

4747
While the docker container/db server is running run the following:
4848
```bash
49-
npx prisma db seed
50-
51-
or
52-
53-
pnpm run seed
49+
$ npx prisma db seed
50+
# or
51+
$ pnpm run seed
5452
```
5553

5654
Then just to be sure run again...
5755

58-
```prisma
59-
npx prisma migrate dev
56+
```sh
57+
$ npx prisma migrate dev
6058
```
6159

62-
Afterwards, seed data is in db already.
60+
After that, seed data is now added.
6361

6462

6563
## API
@@ -80,17 +78,19 @@ model Cafes {
8078
}
8179
8280
model Employees {
83-
id Int @id @default(autoincrement())
84-
createdAt DateTime @default(now())
85-
updatedAt DateTime @updatedAt
86-
name String
87-
email_address String
88-
phone_number String
89-
days_worked Int
90-
cafe Cafes @relation(fields: [cafesId], references: [id])
91-
cafesId Int
81+
id Int @id @default(autoincrement())
82+
createdAt DateTime @default(now())
83+
updatedAt DateTime @updatedAt
84+
name String
85+
cafesId Int
86+
days Int
87+
email String
88+
phone String
89+
gender String
90+
cafe Cafes @relation(fields: [cafesId], references: [id])
9291
}
9392
93+
9494
```
9595

9696
### Default service api url
@@ -113,59 +113,178 @@ http://location:8888
113113
* UPDATE: /cafes/:id (PATCH)
114114
* DELETE: /cafes/:id (DELETE)
115115

116-
### Sample
116+
## Sample Data
117117

118-
**Create Cafes**
119-
<img src="screenshots/cafe.png" />
120-
Request:
118+
### Cafes (http://localhost:8888/cafes)
121119
```json
122-
{
123-
"name": "Cafe2",
124-
"description": "Some desc",
125-
"employees": 2,
126-
"logo": "somelogo.png",
127-
"location": "sg"
128-
}
129-
120+
[
121+
{
122+
"id": 1,
123+
"name": "Digong Cafe",
124+
"createdAt": "2024-09-19T21:26:04.929Z",
125+
"updatedAt": "2024-09-19T21:26:04.929Z",
126+
"description": "Lorem ipsum dolor sit amet",
127+
"logo": "https://gravatar.com/avatar/ef7b90c86c01dea8b4313dbb1cd0d015?s=400&d=robohash&r=x",
128+
"location": "Tampines",
129+
"employees": [
130+
{
131+
"id": 1,
132+
"createdAt": "2024-09-19T21:26:04.975Z",
133+
"updatedAt": "2024-09-19T21:26:04.975Z",
134+
"name": "Alice Guo",
135+
"cafesId": 1,
136+
"days": 7,
137+
"email": "alice.guo@prisma.io",
138+
"phone": "+6588888888",
139+
"gender": "F"
140+
},
141+
{
142+
"id": 2,
143+
"createdAt": "2024-09-19T21:26:04.992Z",
144+
"updatedAt": "2024-09-19T21:26:04.992Z",
145+
"name": "Cassandra Ong",
146+
"cafesId": 1,
147+
"days": 7,
148+
"email": "cass.ong@prisma.io",
149+
"phone": "+6588888888",
150+
"gender": "F"
151+
}
152+
]
153+
},
154+
{
155+
"id": 2,
156+
"name": "Farm Cafe",
157+
"createdAt": "2024-09-19T21:26:04.957Z",
158+
"updatedAt": "2024-09-19T21:26:04.957Z",
159+
"description": "Lorem ipsum dolor sit amet",
160+
"logo": "https://gravatar.com/avatar/24f7432224dd89ca643bec40d21861a7?s=400&d=robohash&r=x",
161+
"location": "Jurong",
162+
"employees": [
163+
{
164+
"id": 4,
165+
"createdAt": "2024-09-19T21:26:05.011Z",
166+
"updatedAt": "2024-09-19T21:26:05.011Z",
167+
"name": "Monkey D. Luffy",
168+
"cafesId": 2,
169+
"days": 7,
170+
"email": "1piece@prisma.io",
171+
"phone": "+6588888888",
172+
"gender": "M"
173+
}
174+
]
175+
},
176+
{
177+
"id": 3,
178+
"name": "Pogo Cafe",
179+
"createdAt": "2024-09-19T21:26:04.966Z",
180+
"updatedAt": "2024-09-19T21:26:04.966Z",
181+
"description": "Lorem ipsum dolor sit amet",
182+
"logo": "https://gravatar.com/avatar/1db0c9ee9a6da87ee2416ea23dfab10d?s=400&d=robohash&r=x",
183+
"location": "Raffles",
184+
"employees": [
185+
{
186+
"id": 3,
187+
"createdAt": "2024-09-19T21:26:05.002Z",
188+
"updatedAt": "2024-09-19T21:26:05.002Z",
189+
"name": "Bratanila SD",
190+
"cafesId": 3,
191+
"days": 365,
192+
"email": "sd@prisma.io",
193+
"phone": "+6588888888",
194+
"gender": "F"
195+
}
196+
]
197+
}
198+
]
130199
```
131200

132-
Response
133-
```json
134-
{
135-
"id": 3,
136-
"name": "Cafe2",
137-
"description": "Some desc",
138-
"employees": 2,
139-
"logo": "somelogo.png",
140-
"location": "sg"
141-
}
142-
```
143201
----
144-
**Create Employees**
145-
<img src="screenshots/employee.png" />
146202

147-
Request:
148-
```json
149-
{
150-
"name": "Employee1",
151-
"email_address": "test@test.com",
152-
"phone_number": "+658888888",
153-
"days_worked": 1,
154-
"cafe": "Cafe1"
155-
}
203+
### Employees (http://localhost:8888/employees)
156204

157-
```
158-
159-
Response
160205
```json
161-
{
162-
"id": 1,
163-
"name": "Employee1",
164-
"email_address": "test@test.com",
165-
"phone_number": "+658888888",
166-
"days_worked": 1,
167-
"cafe": "Cafe1"
168-
}
206+
[
207+
{
208+
"id": 1,
209+
"createdAt": "2024-09-19T21:26:04.975Z",
210+
"updatedAt": "2024-09-19T21:26:04.975Z",
211+
"name": "Alice Guo",
212+
"cafesId": 1,
213+
"days": 7,
214+
"email": "alice.guo@prisma.io",
215+
"phone": "+6588888888",
216+
"gender": "F",
217+
"cafe": {
218+
"id": 1,
219+
"name": "Digong Cafe",
220+
"createdAt": "2024-09-19T21:26:04.929Z",
221+
"updatedAt": "2024-09-19T21:26:04.929Z",
222+
"description": "Lorem ipsum dolor sit amet",
223+
"logo": "https://gravatar.com/avatar/ef7b90c86c01dea8b4313dbb1cd0d015?s=400&d=robohash&r=x",
224+
"location": "Tampines"
225+
}
226+
},
227+
{
228+
"id": 2,
229+
"createdAt": "2024-09-19T21:26:04.992Z",
230+
"updatedAt": "2024-09-19T21:26:04.992Z",
231+
"name": "Cassandra Ong",
232+
"cafesId": 1,
233+
"days": 7,
234+
"email": "cass.ong@prisma.io",
235+
"phone": "+6588888888",
236+
"gender": "F",
237+
"cafe": {
238+
"id": 1,
239+
"name": "Digong Cafe",
240+
"createdAt": "2024-09-19T21:26:04.929Z",
241+
"updatedAt": "2024-09-19T21:26:04.929Z",
242+
"description": "Lorem ipsum dolor sit amet",
243+
"logo": "https://gravatar.com/avatar/ef7b90c86c01dea8b4313dbb1cd0d015?s=400&d=robohash&r=x",
244+
"location": "Tampines"
245+
}
246+
},
247+
{
248+
"id": 3,
249+
"createdAt": "2024-09-19T21:26:05.002Z",
250+
"updatedAt": "2024-09-19T21:26:05.002Z",
251+
"name": "Bratanila SD",
252+
"cafesId": 3,
253+
"days": 365,
254+
"email": "sd@prisma.io",
255+
"phone": "+6588888888",
256+
"gender": "F",
257+
"cafe": {
258+
"id": 3,
259+
"name": "Pogo Cafe",
260+
"createdAt": "2024-09-19T21:26:04.966Z",
261+
"updatedAt": "2024-09-19T21:26:04.966Z",
262+
"description": "Lorem ipsum dolor sit amet",
263+
"logo": "https://gravatar.com/avatar/1db0c9ee9a6da87ee2416ea23dfab10d?s=400&d=robohash&r=x",
264+
"location": "Raffles"
265+
}
266+
},
267+
{
268+
"id": 4,
269+
"createdAt": "2024-09-19T21:26:05.011Z",
270+
"updatedAt": "2024-09-19T21:26:05.011Z",
271+
"name": "Monkey D. Luffy",
272+
"cafesId": 2,
273+
"days": 7,
274+
"email": "1piece@prisma.io",
275+
"phone": "+6588888888",
276+
"gender": "M",
277+
"cafe": {
278+
"id": 2,
279+
"name": "Farm Cafe",
280+
"createdAt": "2024-09-19T21:26:04.957Z",
281+
"updatedAt": "2024-09-19T21:26:04.957Z",
282+
"description": "Lorem ipsum dolor sit amet",
283+
"logo": "https://gravatar.com/avatar/24f7432224dd89ca643bec40d21861a7?s=400&d=robohash&r=x",
284+
"location": "Jurong"
285+
}
286+
}
287+
]
169288
```
170289

171290

0 commit comments

Comments
 (0)