Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: What is Eve?
Lecture: Exploring Eve: Queries

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Speaking about queries, let's see
0:03 how we could perform queries against our remote API.
0:06 Let's say that we want to find all the people where last name is Green.
0:12 So we go over here to the URL and we set a query string
0:17 we use the where keyword
0:20 and then we go with a Mongo syntax,
0:23 you can see here it is basically a Json object
0:27 so find all the documents where last name is Green.
0:31 Let's try this one, and as you can see,
0:35 we only have one document back
0:37 and it is exactly what we were looking for,
0:40 let's try something more complex
0:42 and find all the documents where last name is Green
0:45 and also location.city is Ravena, which is my hometown in Italy.
0:59 Zero documents back, and that makes sense,
1:04 it is what we expected, as you can see, the items array is empty.
1:07 Now if we go back to my query and replace Ravena with New York
1:12 I should get back my Green guy again.
1:18 Because location city is in fact New York,
1:22 so as you can see, you can also query on subdocuments,
1:25 like we did here using the . syntax
1:28 you can chain multiple conditions
1:30 and you can basically use
1:32 all of the MongoDB supported operators like or, and, etc.
1:38 You have also another option,
1:40 if you don't like the Mongo syntax,
1:42 maybe you are not familiar with it,
1:44 you can actually use the Python syntax, which is different,
1:50 let's try one example where last name=green
1:57 same result, as you can see.
2:04 So different syntax, similar result.
2:09 Now we will see in the following segments
2:12 that you can actually configure your API
2:16 and decide which syntax you want to support,
2:19 by default, both of them are allowed,
2:21 but you can actually turn Python syntax off
2:25 or Mongo syntax on and off, however you please.