background preloader

MongoDB

Facebook Twitter

Mongodb For Rubyists at NYC.rb. Skinandbones's rack-gridfs at master - GitHub. GridFS. GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16MB. Instead of storing a file in a single document, GridFS divides a file into parts, or chunks, and stores each of those chunks as a separate document. By default GridFS limits chunk size to 255k.

GridFS uses two collections to store files. One collection stores the file chunks, and the other stores file metadata. When you query a GridFS store for a file, the driver or client will reassemble the chunks as needed. You can perform range queries on files stored through GridFS. GridFS is useful not only for storing files that exceed 16MB but also for storing any files for which you want access without having to load the entire file into memory.

Changed in version 2.4.10: The default chunk size changed from 256k to 255k. Implement GridFS To store and retrieve files using GridFS, use either of the following: A MongoDB driver. GridFS Collections GridFS stores files in two collections: More MongoMapper Awesomeness. September was a month of craziness and for the first month in quite a while I did not post here. I promise it hurt me as much as it hurt you. In an effort to get back in the rhythm, I am going to start with an easy article. MongoMapper has been getting a lot of love lately and I thought I would mention some of the awesomeness. Dynamic Finders Dynamic finders are so darn handy in ActiveRecord. Class User include MongoMapper::Document many :posts end class Post include MongoMapper::Document key :user_id, ObjectId key :title, String end user = User.create user.posts.create(:title => 'Foo') # would return post we just created user.posts.find_by_title('Foo') Document associations now also have all the normal Rails association methods such as build, create, find, etc.

Logging The mongo ruby driver added logging support so a few days ago, I added some basic support for accessing and using that logger from within MongoMapper. Tailing the log would give you output like the following: MONGODB db.