Implementing a Grid Object from Node.js
The Grid
object acts as a representation of GridFS. It provides a simple interface to read and write binary data to GridFS. You can instantiate the Grid
object by calling the Grid()
constructor from an instance of the Db
object. For example, the following code connects to MongoDB and creates a Grid
object attached to the fs
collection:
MongoClient.connect("mongodb://localhost/", function(err, db) { var grid= new Grid(db, 'fs');});
The Grid
object provides several methods that allow you to put data into the grid, retrieve data in the grid, and remove data from the grid. The data stored in the grid is stored in binary format, so it must be put into the grid and read from the ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.