Grid()

Constructor

A class representation of a simple Grid interface.

class Grid()
Arguments:
  • db (db) – A database instance to interact with.
  • [fsName] (string) – optional different root collection for GridFS.
Returns:

grid

put

Puts binary data to the grid

Options
  • _id {Any}, unique id for this file
  • filename {String}, name for this file.
  • root {String}, root collection to use. Defaults to {GridStore.DEFAULT_ROOT_COLLECTION}.
  • content_type {String}, mime type of the file. Defaults to {GridStore.DEFAULT_CONTENT_TYPE}.
  • chunk_size {Number}, size for the chunk. Defaults to {Chunk.DEFAULT_CHUNK_SIZE}.
  • metadata {Object}, arbitrary data the user wants to store.
put(data, [options, ]callback)
Arguments:
  • data (buffer) – buffer with Binary Data.
  • [options] (object) – the options for the files.
  • callback (function) – this will be called after this method is executed. The first parameter will contain an Error object if an error occured or null otherwise. The second parameter will contain a reference to this object.
Returns:

null

get

Get binary data to the grid

get(id, callback)
Arguments:
  • id (any) – for file.
  • callback (function) – this will be called after this method is executed. The first parameter will contain an Error object if an error occured or null otherwise. The second parameter will contain a reference to this object.
Returns:

null

delete

Delete file from grid

delete(id, callback)
Arguments:
  • id (any) – for file.
  • callback (function) – this will be called after this method is executed. The first parameter will contain an Error object if an error occured or null otherwise. The second parameter will contain a reference to this object.
Returns:

null

Contents

Manual

MongoDB Wiki