Navigation
This version of the documentation is archived and no longer supported. To learn how to upgrade your version of PHP Library Manual, refer to the upgrade documentation.

MongoDB\GridFS\Bucket::delete()

Definition

MongoDB\GridFS\Bucket::delete

Delete a file and its chunks from the GridFS bucket.

function delete($id): void

This method has the following parameters:

Parameter Type Description
$id mixed The _id of the file.

Errors/Exceptions

MongoDB\GridFS\Exception\FileNotFoundException if no file was found for the selection criteria.

MongoDB\Driver\Exception\RuntimeException for other errors at the driver level (e.g. connection errors).

Behavior

If the files collection document is not found, this method will still attempt to delete orphaned chunks.