gridstorage
v1.1.1
Published
GridFS + Mongoose helper
Downloads
11
Readme
gridstorage
GridFS + Mongoose helper
Installation
npm i gridstorage
API
new Storage(mongodb) : Storage
const Storage = require('gridstorage');
const mongo = require('mongodb');
const { MongoClient } = mongodb
MongoClient.connect(uri, (err, db) => {
if (err) {
throw new Error(err);
}
const storage = new Storage(mongo, db);
To use with Mongoose:
new Storage(mongoose) : Storage
const Storage = require('gridstorage');
const mongoose = require('mongoose');
const storage = new Storage(mongoose);
Storage.bucket(bucketName) : Bucket
const videoBucket = storage.bucket('videos');
Bucket.count(filename) : Promise –> Number
if (await videoBucket.count(filename) > 0) {
return next('Video exists');
}