For Lab Practice purposes, we will select the zips
collection from sample_training
database.
The filter text box lets us specify the conditions for the query. {field : "value"}
is the form in which the filter is specified. Suppose we want to access all the documents that has a state field set to NY
and city set to ALBANY
. The following will be written as the filter and click the apply button
{state: "NY", city: "ALBANY"}
Problem:
In the sample_training.trips collection a person with birth year 1961 took a trip that started at "Howard St & Centre St". What was the end station name for that trip?
Copy and paste your answer from the Atlas UI to the response text box. The station name should be in a single set double quotes, exactly as it is in the Data Explorer.
mongodb+srv://username:password@<Atlas Cluster URI>.mongodb.net/admin
show dbs
db.<collection_name>.find(<query>);
use sample_training
show collections
db.zips.find({state : "NY"})
The query goes inside the parenthesisit
can be typed to iterate over the remaining documents. It iterates through a cursor. A cursor is a pointer to the result set of the querycount()
directive after the query. For example, to retrieve the number of documents from New York, db.zips.find({state: "NY"}).count()
pretty()
directive after the query