WEBVTT

0
00:00.210 --> 00:02.730
So what is the difference between put and patch?

1
00:03.300 --> 00:04.870
Well, here's a good analogy.

2
00:05.070 --> 00:10.410
Recently I went onto Amazon and I found a really nice looking bicycle.

3
00:10.770 --> 00:17.070
And because I really wanted to poison my lungs by exercising around London, I clicked on the Buy Now

4
00:17.070 --> 00:17.530
button.

5
00:17.730 --> 00:23.040
So there I was, super happy, super excited for my bicycle to arrive.

6
00:23.310 --> 00:29.880
And then on the day of arrival, I opened up that box and my bicycle was really messed up.

7
00:29.880 --> 00:31.640
The whole front wheel was broken.

8
00:31.950 --> 00:37.860
So I'm not really sure what happened at the Amazon warehouse, but I got in touch with them and I wanted

9
00:37.860 --> 00:40.200
to try and figure out how we can solve this problem.

10
00:40.410 --> 00:43.350
So there were two ways that they could fix this problem.

11
00:43.560 --> 00:47.760
Option one was they send me an entire new bike.

12
00:47.940 --> 00:55.860
So this is the equivalent of put. You're updating your database by sending an entire entry to replace

13
00:55.860 --> 00:56.760
the previous one.

14
00:57.570 --> 01:03.650
Now, the other option Amazon offered was for them to simply send me a new tire.

15
01:03.840 --> 01:05.760
That was the only thing that was broken,

16
01:06.030 --> 01:07.530
the rest of the bike was fine.

17
01:07.770 --> 01:13.890
And in order to save the world from carbon emissions, shipping a wheel is much better than shipping

18
01:13.890 --> 01:15.410
an entire bicycle.

19
01:15.930 --> 01:18.120
And this is the same as Patch.

20
01:18.360 --> 01:25.920
So when you're sending a patch request to the server, you're only sending the piece of data that needs

21
01:25.920 --> 01:30.950
to be updated. Instead of the entire entry that will be replaced,

22
01:31.170 --> 01:34.870
you're simply just updating the thing that needs to be updated.

23
01:34.890 --> 01:41.530
So when we see this in practice, I want you to think back to this bicycle analogy and maybe it'll help you try

24
01:41.530 --> 01:44.010
and understand the difference between these two words.