1 00:00:02,140 --> 00:00:09,970 Now being able to push new values is nice but due to my little example, we now got some duplicate data 2 00:00:09,970 --> 00:00:18,520 here, hiking and good wine is in there too often. We can of course also pull data from an array, 3 00:00:18,880 --> 00:00:25,560 so what I can do here is I can again update one document and that will be Maria, 4 00:00:25,570 --> 00:00:30,270 so name Maria but here, I 5 00:00:30,280 --> 00:00:31,760 then don't use push 6 00:00:31,840 --> 00:00:40,270 but pull. Now pull takes an object where I describe how I want to pull or what I want to pull and here 7 00:00:40,270 --> 00:00:42,610 I can say from the hobbies array, 8 00:00:42,850 --> 00:00:46,300 I want to pull based on a condition which I then specify here, 9 00:00:46,630 --> 00:00:53,810 I want to pull every element where the title is equal to hiking 10 00:00:53,810 --> 00:01:00,540 let's say. With this command, if I now hit enter, you see one document was modified 11 00:01:00,740 --> 00:01:07,040 and if I now find all documents, we see Maria has no hiking in there. 12 00:01:07,160 --> 00:01:11,320 So of course we can now repeat that with good wine to get rid of that too, 13 00:01:11,690 --> 00:01:12,860 just like this 14 00:01:12,910 --> 00:01:18,080 and of course you could not just search for equality here, you could use greater than, all these normal 15 00:01:18,080 --> 00:01:19,890 filter operators you know, 16 00:01:20,180 --> 00:01:24,250 so now the good wine was also removed from Maria. 17 00:01:24,330 --> 00:01:28,360 Sometimes you also just want to remove the last element of an array, 18 00:01:28,410 --> 00:01:35,460 so you have no specific filter criteria, you just want to remove the last element. For that, let's mix 19 00:01:35,460 --> 00:01:45,810 it up and let's update a document where the name is Chris and for Chris, you see the last element 20 00:01:45,810 --> 00:01:47,550 is hiking, 21 00:01:47,600 --> 00:01:52,440 so let's say we want to remove that and we can do that with the 22 00:01:52,490 --> 00:02:00,620 $pop operator here. You then simply define the name of the field of which you want to pop, hobbies 23 00:02:00,630 --> 00:02:02,380 for example. 24 00:02:02,400 --> 00:02:07,800 Now the value here defines if you want to remove the last element, that would be done if you add one 25 00:02:07,800 --> 00:02:08,220 here 26 00:02:08,250 --> 00:02:12,780 or if you actually want to pop off the first element which you could do with -1. 27 00:02:13,070 --> 00:02:16,760 So let's do one, it modified one document 28 00:02:16,860 --> 00:02:20,210 and if I find all users, you'll see that for Chris, 29 00:02:20,280 --> 00:02:26,550 indeed there are only two hobbies and hiking which we previously had with a frequency of zero is gone. 30 00:02:26,550 --> 00:02:31,730 So that is pop which is great if you want to remove the first or last item of an array.