1 00:00:02,090 --> 00:00:03,550 Now that was the exists 2 00:00:03,560 --> 00:00:06,680 operator, what is type all about? 3 00:00:07,160 --> 00:00:10,630 Let's go back to our users and find them all 4 00:00:10,850 --> 00:00:18,460 and of course I did not by accident add phone numbers which for two users are strings 5 00:00:18,470 --> 00:00:21,110 and for Max, it's a number. 6 00:00:21,110 --> 00:00:26,170 Now that gives us an opportunity to work with the type operator, 7 00:00:26,420 --> 00:00:29,100 so let's, whoops, on the users collection, 8 00:00:29,150 --> 00:00:38,930 let's find all users where the type of the phone number is a number let's say and for that, I'll look 9 00:00:38,930 --> 00:00:44,950 for that phone number and then I can use type and then specify the type it should be. 10 00:00:44,960 --> 00:00:48,390 Now the types available can be seen in the official docs, 11 00:00:48,420 --> 00:00:55,040 if you check out the type here, you will find the available types and these are the types I also touched 12 00:00:55,040 --> 00:00:59,140 on in my document schema module, 13 00:00:59,150 --> 00:01:06,170 so here you see we got string, we get doubles which are floating point numbers but we also got like the 14 00:01:06,170 --> 00:01:12,760 big integer, decimal 128 which I'll also come back to in the numbers module in this course, the numeric data 15 00:01:12,770 --> 00:01:14,000 module I should say. 16 00:01:14,120 --> 00:01:16,470 So these are two different types of data 17 00:01:16,580 --> 00:01:23,210 you could have and you can check for, also things like object or array or object ID, 18 00:01:23,720 --> 00:01:27,050 so these are the types you can check for. 19 00:01:27,170 --> 00:01:28,600 Now here it's pretty simple, 20 00:01:28,610 --> 00:01:36,740 I want to find all phone numbers, all documents with phone numbers where the phone number is a number. Now number 21 00:01:36,740 --> 00:01:40,500 is an alias that basically sums up floats and integers, 22 00:01:40,730 --> 00:01:42,020 so this does work, 23 00:01:42,230 --> 00:01:50,400 if I would look for a double, it would also work though even though I have no decimal places here by 24 00:01:50,400 --> 00:01:58,260 default since the shell is based on Javascript, a number I insert into my database will be stored as 25 00:01:58,260 --> 00:02:00,570 a floating point number, as a double 26 00:02:00,570 --> 00:02:07,110 because javascript again which drives the shell doesn't know integers and doubles, it only knows doubles 27 00:02:07,230 --> 00:02:09,680 so it takes that and stores it as a double 28 00:02:09,720 --> 00:02:16,470 even if we have no decimal places, this is why I can find this for double too. 29 00:02:16,500 --> 00:02:18,860 You can also use type a bit differently 30 00:02:19,990 --> 00:02:21,910 and you can specify multiple types, 31 00:02:21,910 --> 00:02:22,820 that would be ok, 32 00:02:22,930 --> 00:02:25,950 you then simply pass an array to type 33 00:02:26,040 --> 00:02:32,650 and here you can say it's ok if it's a double or let's say if it's a string and therefore now, I find 34 00:02:32,740 --> 00:02:35,850 all documents because they all either have a double, 35 00:02:35,850 --> 00:02:38,430 so a number or a string, 36 00:02:38,740 --> 00:02:41,380 you can of course also filter for just strings. 37 00:02:41,380 --> 00:02:42,750 So this is the type 38 00:02:42,760 --> 00:02:49,150 operator and how you can use it to make sure you only work with the right type of data when returning 39 00:02:49,150 --> 00:02:50,010 some documents.