mongoose-gridfs-extra

Home > mongoose-gridfs-extra

mongoose-gridfs-extra package

A simple wrapper for mongodb gridfs bucket.

Functions

Function Description
createGridFSBucket(db, options) create a gridFS bucket object to store files into mongodb
deleteById(bucket, id) deleteById deletes the specified file stored in the mongodb bucket by id. If id is string or number, new ObjectId(id) will be called to convert it to an ObjectId
getGridFSBucketDb(bucket) <p>getGridFSBucketDb returns mongodb Db instance which is used to create this bucket.</p><p>this not a wrapper of mongodb public native api, so use this method carefully</p>
getGridFSBucketName(bucket) <p>getGridFSBucketName returns the bucket’s name</p><p>this not a wrapper of mongodb public native api, so use this method carefully</p>
getGridFSBucketOptions(bucket) <p>getGridFSBucketDb returns mongodb gridFS bucket options which is used to create this bucket.</p><p>this not a wrapper of mongodb public native api, so use this method carefully</p>
readAndDeleteById(bucket, id) readAndDeleteById deletes the specified file stored in the mongodb bucket by id, and returns the file contents. If id is string or number, new ObjectId(id) will be called to convert it to an ObjectId
readFileById(bucket, id, options) readFileById returns Buffer read from specified file stored in mongodb bucket by objectId
readFileByName(bucket, fileName, options) readFileByName returns Buffer read from specified file stored in mongodb bucket by fileName
readFileWithStream(downloadStream) readFileWithStream reads a file from gridFS bucket using the provided stream
writeFileById(bucket, id, file, fileName, options) readFileByName stores file into gridFS bucket by id
writeFileByName(bucket, file, fileName, options) readFileByName stores file into gridFS bucket by fileName
writeFileWithStream(uploadStream, file) writeFileWithStream store a file into gridFS bucket using the provided stream. This function will overwrite the