Docs Menu

Docs HomePHP Library Manual

MongoDB\GridFS\Bucket::drop()

On this page

  • Definition
  • Errors/Exceptions
  • Examples
MongoDB\GridFS\Bucket::drop()

Drops the files and chunks collections associated with this GridFS bucket.

function drop(): void

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

<?php
$database = (new MongoDB\Client)->test;
$bucket = $database->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$bucket->uploadFromStream('filename', $stream);
$bucket->drop();
←  MongoDB\GridFS\Bucket::downloadToStreamByName()MongoDB\GridFS\Bucket::find() →