Introduction
In the previous post we started discussing queries in MongoDb. Specifically we looked at the find and findOne functions. Both can accept a JSON parameter – a JSON document to be exact – to limit the result set returned. find() returns all documents that match the filter or return all documents if there was no filter provided. findOne will always return a single document even if there are more that match the criteria. findOne can be very useful if you’d like to get familiar with a collection by viewing one of its documents. We’ve also quickly looked at two additional functions. The pretty() function produces a better formatted JSON result set on the screen whereas the count() function returns the number of documents within a collection.
In this post we’ll step back a little from querying and instead look at how to import data into a MongoDb database. Specifically we’ll create two real-life collections. We don’t want to keep adding the records ourselves, that’s very tedious. There are at least two different readily available and importable MongoDb collections. The goal is to be able to run meaningful and real-life queries against realistic data sets.
Read more of this post