Database Reference
In-Depth Information
which parts of the document are common to all posts and which can vary. In this case, we
would store different data for a photo post versus a status update, while still keeping the
metadata (
_id
,
by
,
circles
,
type
,
ts
, and
comments
) the same.
Dependent Collections
In addition to independent collections, for optimal performance we'll need to create a few de-
pendent collections that will be used to cache information for display. The first of these col-
lections is the
social.wall
collection, and is intended to display a “wall” containing posts
created by or directed to a particular user. The format of the
social.wall
collection follows:
{
_id
:
ObjectId
(...),
user_id
:
"T4Y...AE"
,
month
:
'201204'
,
posts
:
[
{
id
:
ObjectId
(...),
ts
:
ISODateTime
(...),
by
:
{
id
:
"T4Y...AE"
,
name
:
'Max'
},
circles
:
[
'*public*'
],
type
:
'status'
,
detail
:
{
text
:
'Loving MongoDB'
},
comments_shown
:
3
,
comments
:
[
{
by
:
{
id
:
"T4Y...AG"
,
name
:
'Dwight'
,
ts
:
ISODateTime
(...),
text
:
'Right on!'
},
...
only last
3
comments listed
...
]
},
{
id
:
ObjectId
(...),
s
ts
:
ISODateTime
(...),
by
:
{
id
:
"T4Y...AE"
,
name
:
'Max'
},
circles
:
[
'*circles*'
],
type
:
'checkin'
,
detail
:
{
text
:
'Great office!'
,
geo
:
[
40.724348
,
-
73.997308
],
name
:
'10gen Office'
,
photo
:
'http://....'
},
comments_shown
:
1
,
comments
:
[
{
by
:
{
id
:
"T4Y...AD"
,
name
:
'Jared'
},