WEBVTT

1
00:00:01.979 --> 00:00:07.780
So, I had to remove quite a bit of code because of that lack of knowledge about my code base

2
00:00:07.780 --> 00:00:13.720
and that's why I will now switch to this other chat here where I can add the workspace

3
00:00:13.720 --> 00:00:17.720
reference so that it hopefully will analyze my entire code.

4
00:00:18.800 --> 00:00:28.440
And I'll say edit the, and then I'll point at a file, the events.js routes file here,

5
00:00:28.760 --> 00:00:38.280
edit the file to reach out to the database I want to say but actually for that I'll create

6
00:00:38.280 --> 00:00:48.420
a controller file, event or events controller.js and I'll add a models file here, event.js.

7
00:00:48.700 --> 00:00:54.800
So more manual coding here now with GitHub Copilot and I'll start in the models file

8
00:00:54.800 --> 00:00:56.120
now that I think about it.

9
00:00:56.380 --> 00:01:02.320
And here I now want to add some code to reach out to a database to store event data, find

10
00:01:02.320 --> 00:01:05.120
an event by ID, update an event or delete an event.

11
00:01:06.100 --> 00:01:13.520
So again we can actually use the inline code here or what I'll do, use the chat and edit

12
00:01:17.760 --> 00:01:28.800
the event.js file in the models folder to contain and export functions that will create

13
00:01:28.800 --> 00:01:39.220
a new event with title, description, address and date, I'll take care of the image later,

14
00:01:41.380 --> 00:01:49.280
edit an event, delete an event or get all or a single event by ID.

15
00:01:50.900 --> 00:01:55.400
So that's the features I want to add to this event.js file.

16
00:01:55.880 --> 00:02:00.460
With that let's see what we get, takes a look at my workspace, hopefully understands how

17
00:02:00.460 --> 00:02:04.240
the code looks in the other files, hopefully understands which kind of database I'm using

18
00:02:07.020 --> 00:02:07.860
but it's not.

19
00:02:08.240 --> 00:02:12.980
It's again creating this events array here which is not helpful.

20
00:02:14.220 --> 00:02:23.760
So I'll explicitly tell it I'm using a SQLite database, update the and now I want to update

21
00:02:23.760 --> 00:02:33.860
the database.js file to also contain a fitting events table.

22
00:02:35.500 --> 00:02:42.500
Use this database from this file and then I'll point at this event.js file in the models

23
00:02:42.500 --> 00:02:49.580
folder again to perform the tasks mentioned before.

24
00:02:52.679 --> 00:03:01.800
So now it's trying to tweak the database.js file by also creating an events table in there

25
00:03:04.540 --> 00:03:09.020
and it then tries to tweak the event.js file in the models folder to use that database

26
00:03:09.020 --> 00:03:11.540
to insert events, edit events and so on.

27
00:03:11.560 --> 00:03:12.580
So that looks a bit better.

28
00:03:14.320 --> 00:03:19.900
So I'll actually apply these changes to the database.js file.

29
00:03:22.980 --> 00:03:27.100
Here we go, no that's the wrong file, don't save.

30
00:03:29.780 --> 00:03:39.380
Database.js, apply, okay that looks better and it only changes this part where it adds

31
00:03:39.380 --> 00:03:46.660
the events database which makes sense which is what it should do and it adds an ID, title,

32
00:03:46.760 --> 00:03:52.360
description, address, date, that looks good, we'll add the image later so that works and

33
00:03:52.380 --> 00:04:04.660
then it should update the events.js file in the model folder, the event.js file, sorry,

34
00:04:05.000 --> 00:04:14.560
it should update this so let's apply that here, yeah, did not do that so I'll insert

35
00:04:14.580 --> 00:04:17.120
that cursor instead since the file was empty anyways.

36
00:04:18.800 --> 00:04:21.620
With that this code is added here.

