/mongoose-blob-store

store blobs using mongoose-gridfs

Primary LanguageJavaScriptApache License 2.0Apache-2.0

mongoose-blob-store

store blobs using mongoose gridfs

npm version Build Status

blob-store-compatible

compatible with the abstract-blob-store API and passes its test suite

eg. Usage

Please note that the configuration has a breaking change since v0.*

const store = require('mongoose-blob-store');
// connect mongoose to mongo db then use the connection
const mongooseConnection = require('mongoose').connection;
const blobStorage = store({
  mongooseConnection,
  collection: 'attachments',
  modelName: 'Attachment',
});

//write
blobStorage.createWriteStream(opts, cb);

//read
const stream = blobStorage.createReadStream(opts);

//remove
blobStorage.remove(opts, cb);

//check if file exists
blobStorage.exists(opts, cb);

pull requests are welcome