O'Reilly logo

Node.js, MongoDB, and AngularJS Web Development by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a GridStore Object from Node.js

The GridStore object acts as a representation of a binary file stored in the MongoDB GridFS. It provides the basic file interface to read and write files stored in GridFS. For example, you can stream reads and writes from GridFS, read chunks of a file without needing to read the entire file, etc. These are all things that you could do within Node.js, but without the added benefits that come with MongoDB, such as replication and high availability.

You can instantiate the GridStore object by calling the GridStore() constructor from an instance of the Db object. For example, the following code connects to MongoDB and creates a GridStore object attached to the fs collection:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required