// Delete deletes all chunks and metadata associated with the file with the given file ID.
//
// If this operation requires a custom write deadline to be set on the bucket, it cannot be done concurrently with other
// write operations operations on this bucket that also require a custom deadline.
Delete deletes all chunks and metadata associated with the file with the given file ID.

If this operation requires a custom write deadline to be set on the bucket, it cannot be done concurrently with other
write operations operations on this bucket that also require a custom deadline.
// Delete deletes all chunks and metadata associated with the file with the given file ID . // // If this operation requires a custom write deadline to be set on the bucket it cannot be done concurrently with other // write operations operations on this bucket that also require a custom deadline .
func (b *Bucket) Delete(fileID interface{}) error {
	ctx, cancel := deadlineContext(b.writeDeadline)
	if cancel != nil {
		defer cancel()
	}
	id, err := convertFileID(fileID)
	if err != nil {
		return err
	}
	res, err := b.filesColl.DeleteOne(ctx, bsonx.Doc{{"_id", id}})
	if err == nil && res.DeletedCount == 0 {
		err = ErrFileNotFound
	}
	if err != nil {
		_ = b.deleteChunks(ctx, fileID) 
		return err
	}
	return b.deleteChunks(ctx, fileID)
}
func ( b * Bucket ) Delete ( fileID interface { } ) error { ctx , cancel := deadlineContext ( b . writeDeadline ) if cancel != nil { defer cancel ( ) } id , err := convertFileID ( fileID ) if err != nil { return err } res , err := b . filesColl . DeleteOne ( ctx , bsonx . Doc { { " " , id } } ) if err == nil && res . DeletedCount == 0 { err = ErrFileNotFound } if err != nil { _ = b . deleteChunks ( ctx , fileID ) return err } return b . deleteChunks ( ctx , fileID ) }
Delete deletes all chunks and metadata associated with the file with the given file ID.
Delete deletes all chunks and metadata associated with the file with the given file ID .
// delete document in files collection and then chunks to minimize race conditions // can attempt to delete chunks even if no docs in files collection matched