Home > mongoose-gridfs-extra > readAndDeleteById
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
Signature:
declare function readAndDeleteById(bucket: mongo.GridFSBucket, id: mongo.ObjectId | string | number): Promise<Buffer>;
| Parameter | Type | Description |
|---|---|---|
| bucket | mongo.GridFSBucket | a mongodb gridFS bucket |
| id | mongo.ObjectId | string | number | id of file to delete |
Returns:
Promise<Buffer>
a promise that resolves to a Buffer