1 00:00:02,150 --> 00:00:10,850 Now we saw inc for increment or actually also as you saw, decrementing a field. Now other useful operators 2 00:00:10,970 --> 00:00:13,610 are min, max and mul, 3 00:00:13,610 --> 00:00:15,710 now let me quickly show you how these work. 4 00:00:15,760 --> 00:00:25,400 Let's again look into our data and let's say now for Chris we want to set the age to 35 but only 5 00:00:25,460 --> 00:00:28,270 if the existing age is higher than that. 6 00:00:28,280 --> 00:00:31,900 Now obviously we see that this is the case but this is another common thing, 7 00:00:31,910 --> 00:00:38,510 a scenario you might encounter, that you want to set some field to a certain value but only if it currently 8 00:00:38,510 --> 00:00:41,880 is higher and not if it is lower, 9 00:00:41,880 --> 00:00:50,260 so let me show you how this would work. For this, we'll simply filter by name again, I'll use update one and 10 00:00:50,260 --> 00:00:54,610 I'll filter for name equal to Chris. 11 00:00:54,610 --> 00:01:04,490 Now here we can use the $min operator and then specify the field name, age and set it to 35. 12 00:01:05,050 --> 00:01:11,710 If I now hit enter, you see one document was found and one document was edited and indeed, if I look into 13 00:01:11,710 --> 00:01:15,950 my data, we see that Chris is now 35. 14 00:01:15,980 --> 00:01:21,040 Now let me show you a case where this will fail or where this will not change anything to be precise. 15 00:01:21,350 --> 00:01:25,380 If I now set min age for Chris to 38, 16 00:01:25,490 --> 00:01:29,320 keep in mind he is currently 35, if I hit enter here, 17 00:01:29,480 --> 00:01:32,480 you see it matched but it didn't change anything, 18 00:01:32,540 --> 00:01:34,480 it didn't throw an error either, 19 00:01:34,550 --> 00:01:36,440 it just did not change anything 20 00:01:36,440 --> 00:01:43,910 and you see the age is still at 35 because min only changes the value if the new value is lower 21 00:01:43,970 --> 00:01:45,700 than the existing value 22 00:01:46,190 --> 00:01:49,280 and the same also exists for max unsurprisingly. 23 00:01:49,280 --> 00:01:55,760 So if I repeat this but I replace min with max and I set it to 32 for a start, 24 00:01:55,760 --> 00:01:58,140 keep in mind Chris is still 35, 25 00:01:58,160 --> 00:02:02,820 so this value is actually lower, then max will not do anything, 26 00:02:03,020 --> 00:02:10,550 if I set it to a higher value like 38, it will update Chris because unlike min, max simply does update 27 00:02:10,740 --> 00:02:15,250 if the old value is lower than the new value. 28 00:02:15,370 --> 00:02:18,910 Now last but not least, we also got mul, multiply. 29 00:02:19,150 --> 00:02:22,350 Let's quickly look into the data to confirm that Chris is 38, 30 00:02:22,540 --> 00:02:23,620 yes he is 31 00:02:24,100 --> 00:02:25,260 and with that confirmed, 32 00:02:25,720 --> 00:02:27,930 let me show you the last operator. 33 00:02:28,400 --> 00:02:32,080 Let me add mul or use mul like this 34 00:02:32,080 --> 00:02:35,730 and now this will multiply the age by a number we specify, 35 00:02:35,950 --> 00:02:41,920 so let's say Chris got 10% older, so we could multiply age by 1.1. 36 00:02:42,400 --> 00:02:49,760 If I hit enter, that succeeded and if we have a look at all the data, we see Chris was 38, now he 37 00:02:49,750 --> 00:02:51,550 is 41.8 38 00:02:51,850 --> 00:02:59,160 and this is something which will become clearer once we are in the numeric data module where I will 39 00:02:59,160 --> 00:03:02,530 talk about this missing precision here 40 00:03:02,770 --> 00:03:10,390 but basically he got 3.8 years older which happens to be 10% of 38, his old age. 41 00:03:10,420 --> 00:03:13,480 So this is the mul, the multiply operator.