1 00:00:02,130 --> 00:00:09,840 Some theory first. When working with mongodb, we can basically talk about methods, filters and operators, 2 00:00:09,990 --> 00:00:14,900 not just for getting data but in general but especially for getting data filters and so on 3 00:00:14,900 --> 00:00:16,430 play an important role. 4 00:00:16,920 --> 00:00:21,950 So in the shell, we access the database with the db command, in a mongodb driver, 5 00:00:21,960 --> 00:00:27,270 this will differ slightly and you'll see it in the from shell to driver module towards the end of the 6 00:00:27,270 --> 00:00:27,820 course 7 00:00:27,960 --> 00:00:32,950 but there too, we will get access to the database and then to a collection in the database, 8 00:00:33,060 --> 00:00:35,390 the same can be done in the shell. 9 00:00:35,730 --> 00:00:42,740 Now then we can execute a method like find, insert also was a method, delete was a method, 10 00:00:42,840 --> 00:00:48,600 so everything which comes after a dot here and then has parentheses like this one is called a method, 11 00:00:48,890 --> 00:00:52,560 a method we execute on the collection in this case. 12 00:00:52,560 --> 00:00:54,980 Now we pass some data to this method, 13 00:00:55,140 --> 00:01:03,060 the parameters of the method, so to say. In find, the first argument or a parameter we can pass is a document 14 00:01:03,150 --> 00:01:05,000 describing what we'll look for, 15 00:01:05,010 --> 00:01:07,440 it has the format of a field name 16 00:01:07,620 --> 00:01:10,320 and then the value for that field name. 17 00:01:10,320 --> 00:01:15,400 Now you will learn that the value is quite flexible when finding data but in the end, this is the structure, 18 00:01:15,480 --> 00:01:16,490 fields and values 19 00:01:16,560 --> 00:01:21,600 and this is also what documents are all about, fields or keys however you want to name it and values 20 00:01:21,720 --> 00:01:23,940 for these names or fields. 21 00:01:23,940 --> 00:01:31,710 Now here, this argument for find happens to be a filter because find accepts a filter, it needs or it 22 00:01:31,710 --> 00:01:35,420 can use a filter to narrow down the set of documents 23 00:01:35,420 --> 00:01:36,600 it returns you. 24 00:01:36,930 --> 00:01:42,900 Here we got equality or a single value filter because we want to find all documents that have an age 25 00:01:42,930 --> 00:01:45,950 field where the age is exactly 32, 26 00:01:45,950 --> 00:01:47,590 so we're looking for equality here, 27 00:01:47,610 --> 00:01:51,570 this is a very simple filter but also one you'll use quite a lot. 28 00:01:51,660 --> 00:01:59,910 Now you can also use more complex filters where you for example see something like this as a value, where 29 00:01:59,910 --> 00:02:07,110 you have another document as a value which in turn has a value and where the field is then an operator 30 00:02:07,350 --> 00:02:13,670 and you can see or you can recognize operators by the dollar sign at the beginning. 31 00:02:13,680 --> 00:02:19,350 These are all reserved fields if you want to call them like this which are understood by mongodb 32 00:02:19,350 --> 00:02:19,850 . 33 00:02:20,070 --> 00:02:27,250 and this operation here as an example is called a range filter because it does not just filter for equality, 34 00:02:27,300 --> 00:02:33,620 instead this will look for all documents that have an age that is greater than, that's what the gt operator 35 00:02:33,630 --> 00:02:38,230 does, that is greater than the value, so greater than 30. 36 00:02:38,510 --> 00:02:44,700 This is how this works and what we will work with in this module, we'll learn a bunch of different operators 37 00:02:45,030 --> 00:02:48,720 and different ways of using them and different ways of filtering therefore. 38 00:02:48,780 --> 00:02:52,070 But in the end, this is always the structure you will recognize.