1
00:00:05,220 --> 00:00:06,180
Welcome back, everyone.

2
00:00:06,330 --> 00:00:12,240
So let's show you how to delete a data entry from your database table, your model, as you can expect,

3
00:00:12,240 --> 00:00:13,380
this is actually super simple.

4
00:00:13,380 --> 00:00:16,170
You just called delete in the same way you called Save.

5
00:00:16,470 --> 00:00:17,800
Let's head over to our code editor.

6
00:00:18,180 --> 00:00:20,750
OK, so here I am again, our editor.

7
00:00:20,910 --> 00:00:27,240
What I'm going to do is let's go ahead and grab the patient who is now called, I believe, jingo Carl.

8
00:00:27,540 --> 00:00:28,560
So let's check this out.

9
00:00:28,560 --> 00:00:31,890
When I say patient, the objects, the all.

10
00:00:32,640 --> 00:00:34,650
And now we have jingo Carl.

11
00:00:35,040 --> 00:00:37,620
Let's go ahead and remove him from our database.

12
00:00:37,770 --> 00:00:40,080
So the first thing to do is actually grab Carl.

13
00:00:40,500 --> 00:00:42,680
So lots of different ways you could do this if you wanted to.

14
00:00:42,700 --> 00:00:46,530
You could use some sort of filter and then say the last name is equal to Jango.

15
00:00:46,830 --> 00:00:53,580
But I already know that I can just say Carl or even like data point whatever you want to call this particular

16
00:00:53,580 --> 00:00:54,660
object is patient.

17
00:00:55,050 --> 00:00:56,950
The objects don't get.

18
00:00:57,360 --> 00:00:59,400
And I know Carl is primary key one.

19
00:00:59,490 --> 00:01:02,460
If I didn't know this primary key, I'd have to start filtering.

20
00:01:02,460 --> 00:01:05,640
So I would say filter where last name is equal to Jango.

21
00:01:05,910 --> 00:01:12,840
Or maybe I use something like a field lookup, you know, last name ends with or starts with Jango.

22
00:01:12,840 --> 00:01:14,940
So lots of different ways I could have gotten this.

23
00:01:15,360 --> 00:01:18,960
But now, if I check out data points again, you can call that variable whatever you want.

24
00:01:19,380 --> 00:01:20,610
I see it's Carl.

25
00:01:21,000 --> 00:01:22,310
So how do I delete this?

26
00:01:22,320 --> 00:01:27,720
I simply say data points or whatever you happen to call this and treat and then call delete.

27
00:01:28,170 --> 00:01:33,000
Open close parentheses obviously want to be very careful at this command because it will remove it from

28
00:01:33,000 --> 00:01:37,770
the database and you need to go back and restore your database to some previously saved st.

29
00:01:38,040 --> 00:01:39,270
In order to get this back.

30
00:01:39,450 --> 00:01:42,080
So we hit delete and it's going to report back.

31
00:01:42,090 --> 00:01:49,560
Oh, by the way, I removed from the office folder model patient index key number one.

32
00:01:50,010 --> 00:01:58,320
So now if I say patient, the object's the all and run that I can see, there is no more Carl Jango.

33
00:01:58,380 --> 00:02:00,060
It's just these other patients here.

34
00:02:00,660 --> 00:02:00,990
OK.

35
00:02:01,020 --> 00:02:05,160
So again, it's pretty simple to delete, but it's obviously command you want to be careful with.

36
00:02:06,160 --> 00:02:07,420
Let's see you in the next lecture.

