How to use the @lykmapipo/mongoose-common.GridFSBucket function in @lykmapipo/mongoose-common

To help you get started, we’ve selected a few @lykmapipo/mongoose-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lykmapipo / mongoose-gridfs / lib / bucket.js View on Github external
function createBucket(optns = {}) {
  // ensure options
  let { connection } = optns;
  connection = (connection || mongoose.connection);
  const options =
    _.merge({}, DEFAULT_BUCKET_OPTIONS, _.omit(optns, 'connection'));

  // create GridFSBucket
  const db = connection.db;
  const bucket = new GridFSBucket(db, options);

  // return bucket
  return bucket;
}