---
name: "mongoc_database_find_collections"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_database_find_collections"
---

# mongoc\_database\_find\_collections(3)

**WARNING:**

Deprecated since version 1.9.0: Use *mongoc\_database\_find\_collections\_with\_opts()* instead.

## SYNOPSIS

```
mongoc_cursor_t *
mongoc_database_find_collections (mongoc_database_t *database,
                                  const bson_t *filter,
                                  bson_error_t *error);
```

## DESCRIPTION

Fetches a cursor containing documents, each corresponding to a collection on this database.

This function is considered a retryable read operation. Upon a transient error (a network error, errors due to replica set failover, etc.) the operation is safely retried once. If **retryreads** is false in the URI (see *mongoc\_uri\_t*) the retry behavior does not apply.

## PARAMETERS

- •

  **database**: A *mongoc\_database\_t*.

- •

  **filter**: A matcher used by the server to filter the returned collections. May be **NULL**.

- •

  **error**: An optional location for a *bson\_error\_t* or **NULL**.

## ERRORS

Errors are propagated via the **error** parameter.

## RETURNS

This function returns a newly allocated *mongoc\_cursor\_t* that should be freed with *mongoc\_cursor\_destroy()* when no longer in use, or *NULL* in case of error. The user must call *mongoc\_cursor\_next()* on the returned *mongoc\_cursor\_t* to execute the initial command.

In the returned cursor each result corresponds to the server's representation of a collection in this database.

The cursor functions *mongoc\_cursor\_set\_limit()*, *mongoc\_cursor\_set\_batch\_size()*, and *mongoc\_cursor\_set\_max\_await\_time\_ms()* have no use on the returned cursor.

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
