@@ -37,29 +37,27 @@ $ pnpm run test:cov
37
37
Use Prisma CLI to apply migrations and generate the Prisma client:
38
38
39
39
``` bash
40
- npx prisma migrate dev
41
- npx prisma generate
40
+ $ npx prisma migrate dev
41
+ $ npx prisma generate
42
42
```
43
43
44
44
### Seed the Cafes and Employees (add dummy data)
45
45
46
46
47
47
While the docker container/db server is running run the following:
48
48
``` 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
54
52
```
55
53
56
54
Then just to be sure run again...
57
55
58
- ``` prisma
59
- npx prisma migrate dev
56
+ ``` sh
57
+ $ npx prisma migrate dev
60
58
```
61
59
62
- Afterwards , seed data is in db already .
60
+ After that , seed data is now added .
63
61
64
62
65
63
## API
@@ -80,17 +78,19 @@ model Cafes {
80
78
}
81
79
82
80
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])
92
91
}
93
92
93
+
94
94
```
95
95
96
96
### Default service api url
@@ -113,59 +113,178 @@ http://location:8888
113
113
* UPDATE: /cafes/: id (PATCH)
114
114
* DELETE: /cafes/: id (DELETE)
115
115
116
- ### Sample
116
+ ## Sample Data
117
117
118
- ** Create Cafes**
119
- <img src =" screenshots/cafe.png " />
120
- Request:
118
+ ### Cafes (http://localhost:8888/cafes)
121
119
``` 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
+ ]
130
199
```
131
200
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
- ```
143
201
----
144
- ** Create Employees**
145
- <img src =" screenshots/employee.png " />
146
202
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)
156
204
157
- ```
158
-
159
- Response
160
205
``` 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
+ ]
169
288
```
170
289
171
290
0 commit comments