1.1.1 • Published 7 years ago
gridstorage v1.1.1
gridstorage
GridFS + Mongoose helper
Installation
npm i gridstorageAPI
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');
}