1 00:00:02,160 --> 00:00:08,790 So after this useful piece of advice, let's now have a look at some dedicated array query selectors that 2 00:00:08,790 --> 00:00:11,220 can help us find the right query, 3 00:00:11,430 --> 00:00:13,410 let's start with size, 4 00:00:13,410 --> 00:00:15,440 size is pretty straightforward 5 00:00:15,780 --> 00:00:24,990 Now here in our collection, if we have a look at all our users, we can see that they all have the same 6 00:00:24,990 --> 00:00:28,460 amount of hobbies, they all have two hobbies. 7 00:00:28,560 --> 00:00:38,360 Now let's therefore add a new user with insertOne and that user will generally follow the scheme and 8 00:00:38,360 --> 00:00:39,410 have a name, 9 00:00:39,410 --> 00:00:41,600 whoops, we don't need to wrap that but we could, 10 00:00:41,630 --> 00:00:43,240 the name is Chris let's say 11 00:00:43,490 --> 00:00:47,800 and we can specify an age and the other parts that doesn't really matter, 12 00:00:47,810 --> 00:00:50,330 let's specify the hobbies that matters. 13 00:00:50,510 --> 00:00:58,120 And we can even use a different approach here and say sports, cooking and hiking, like this, 14 00:00:58,130 --> 00:01:01,290 so here I don't have embedded documents, I could add them, 15 00:01:01,310 --> 00:01:02,370 it really doesn't matter, 16 00:01:02,400 --> 00:01:05,620 to save time and space I'll just use strings. 17 00:01:05,690 --> 00:01:07,960 So now I have one new user in the database, 18 00:01:08,060 --> 00:01:15,190 Chris and now I want to find all users who have three hobbies which should be just Chris because the 19 00:01:15,230 --> 00:01:16,340 other users have two 20 00:01:16,430 --> 00:01:21,040 and it doesn't matter whether a hobby is an embedded document or just a string, 21 00:01:21,080 --> 00:01:28,340 it's just the amount of items in the hobbies array that matters. To find all users with exactly three 22 00:01:28,340 --> 00:01:41,130 hobbies, I can look into my users with find and now the value for find is that I use hobbies and I'm looking 23 00:01:42,650 --> 00:01:46,900 for a size of three, written like this. 24 00:01:47,150 --> 00:01:47,880 If I hit enter, 25 00:01:47,960 --> 00:01:49,570 I only find Chris. 26 00:01:49,730 --> 00:01:54,650 Now what's important to understand about this command by the way is that this has to be an exact number, 27 00:01:54,710 --> 00:01:59,750 you can't say give me anything with more than two items. If you need something like this, 28 00:01:59,900 --> 00:02:02,030 you'll have to retrieve your data differently, 29 00:02:02,030 --> 00:02:06,980 this is something mongodb does not support yet, you can only look for exact matches here.