Database Reference
In-Depth Information
...
type : 'blog-entry' ,
parent_id : ObjectId (...),
slug : '2012-03-noticed-the-news' ,
...,
detail : {
publish_on : ISODate ( ),
text : 'I noticed the news from Washington today…'
}
}
}
Photos require a different approach. Because photos can be potentially large, it's important
to separate the binary photo storage from the node's metadata. GridFS provides the ability to
store larger files in MongoDB.
GridFS
GridFS is actually a convention, implemented in the client , for storing large blobs of binary
data in MongoDB. MongoDB documents are limited in size to (currently) 16 MB. This means
that if your blob of data is larger than 16 MB, or might be larger than 16 MB, you need to split
the data over multiple documents.
This is just what GridFS does. In GridFS, each blob is represented by:
▪ One document that contains metadata about the blob (filename, md5 checksum, MIME
type, etc.), and
▪ One or more documents containing the actual contents of the blob, broken into 256 kB
“chunks.”
While GridFS is not optimized in the same way as a traditional distributed filesystem, it is
often more convenient to use. In particular, it's convenient to use GridFS:
▪ For storing large binary objects directly in the database, as in the photo album example, or
▪ For storing file-like data where you need something like a distributed filesystem but you
don't want to actually set up a distributed filesystem.
As always, it's best to test with your own data to see if GridFS is a good fit for you.
Search WWH ::




Custom Search