SYNOPSIS

char **
mongoc_client_get_database_names (mongoc_client_t *client,
                                  bson_error_t    *error);

DESCRIPTION

The mongoc_client_get_database_names() function shall return a list of database names.

RETURN VALUE

The mongoc_client_get_database_names() function returns the database names in an array of null terminated strings. The array that it returns is also null terminated. The array should be freed with libmongoc:bson_strfreev[3].

In the case of an error, they NULL is returned.

ERRORS

Errors can occur if the mongoc_client(7) cannot execute the associated server side command. In that case, the passed in error parameter can be consulted for more details.

EXAMPLE

bson_error_t error;
char ** names, ** ptr;

names = mongoc_client_get_database_names (client, &error);

if (! names) {
   fprintf(stderr, "Error in get db names: %s\n", error.message);
   exit 1;
}

for (ptr = names; *ptr; ptr++) {
   printf("db: %s\n", *ptr);
}

bson_strfreev (names);

SEE ALSO

AUTHORS

This page was written by MongoDB Inc.