The Mongoid document
MongoDB stores documents that have fields and maybe other documents embedded in it. The documents are stored in collections. This is analogous to records stored in tables. The difference is that documents, unlike records in a SQL database, need not have the same structure or fields. In fact, as we have already seen in the previous chapter, there is no standard structure for storing documents in MongoDB.
So, do we define a default structure when we use Mongoid? Yes, not only can we define some basic default fields in a Mongoid document but we can also add fields dynamically (we saw this in the previous chapter). So we get the best of both worlds. If you have used ActiveRecord migrations earlier, remember that we don't need them anymore as we define the default fields in the model itself.
Documents are stored in the BSON format by MongoDB. BSON (Binary JSON) is a compact format that uses JSON standards for communication, and a serialized format for storage. This gives us...