Database Reference
In-Depth Information
Figure 3.3
The Tweet Archiver output rendered in a web browser
If the application starts without error, you'll see the standard Sinatra startup message:
$ ruby viewer.rb
== Sinatra/1.0.0 has taken the stage on 4567 for development
with backup from Mongrel
You can then point your web browser to http://localhost:4567. The page should look
something like the screenshot in figure 3.3. Try clicking on the links at the top of the
screen to narrow the results to a particular tag.
That's the extent of the application. It's admittedly simple, but it demonstrates
some of the ease of using MongoDB. You didn't have to define your schema in
advance; you took advantage of secondary indexes to make your queries fast and pre-
vent duplicate inserts; and you had a relatively simple integration with your program-
ming language.
3.4
Summary
You've just learned the basics of talking to MongoDB through the Ruby program-
ming language. You saw how easy it is to represent documents in Ruby, and how simi-
lar Ruby's CRUD API is to that of the MongoDB shell. We dove into some internals,
learning how the drivers in general are built and looking in detail at object ID s,
BSON , and the MongoDB network protocol. Finally, you built a simple application to
show the use of MongoDB with real data. Though you certainly shouldn't feel you've
reached MongoDB mastery, the prospect of writing applications with the database
should be in reach.
Beginning with chapter 4, we're going to take everything you've learned so far and
drill down. Specifically, we'll investigate how you might build an e-commerce applica-
tion in MongoDB. That would be an enormous project, so we'll focus solely on a few
sections on the back end. I'll present some data models for that domain, and you'll
see how to insert and query that kind of data.
Search WWH ::




Custom Search