Document-Oriented Datastore

compared with
Current by Kristina Chodorow
on Jul 30, 2009 15:26.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (3)

View page history
When we describe MongoDB as "document oriented", we mean it's in the class of databases for which the primary storage unit is a collection - possibly structured - of data, most likely as key/value pairs.
{redirect:Databases}
Some examples of document formats are [JSON |http://www.json.org], XML, and simple sets of key/value pairs.

For example the following "document" can be stored in Mongo DB:
{code}{ author: 'joe',
created: Date('03-28-2009'),
title: 'Yet another blog post',
text: 'Here is the text...',
tags: [ 'example', 'joe' ],
comments: [ { author: 'jim', comment: 'I disagree' },
{ author: 'nancy', comment: 'Good post' }
]
}
{code}
The Mongo database stores these JSON-style documents in a binary format called [BSON|DOCS:BSON].

MongoDB understands the internals of BSON objects \-\- not only can it store them, it can query on internal fields and index keys based upon them.  For example the query

{code}
db.posts.find( { "comments.author" : "jim" } )
{code}

is possible and means "find any blog post where at least one comment subjobject has author == 'jim'".