.\" This manpage is Copyright (C) 2016 MongoDB, Inc. .\" .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.3 .\" or any later version published by the Free Software Foundation; .\" with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. .\" A copy of the license is included in the section entitled "GNU .\" Free Documentation License". .\" .TH "MONGOC_CLIENT_GET_DEFAULT_DATABASE" "3" "2016\(hy10\(hy12" "MongoDB C Driver" .SH NAME mongoc_client_get_default_database() \- None .SH "SYNOPSIS" .nf .nf mongoc_database_t * mongoc_client_get_default_database (mongoc_client_t *client); .fi .fi Get the database named in the MongoDB connection URI, or .B NULL if the URI specifies none. Useful when you want to choose which database to use based only on the URI in a configuration file. .SH "PARAMETERS" .TP .B client A .B mongoc_client_t . .LP .SH "RETURNS" A newly allocated .B mongoc_database_t that should be freed with .B mongoc_database_destroy(3) . .SH "EXAMPLE" .nf /* default database is "db_name" */ mongoc_client_t *client = mongoc_client_new ("mongodb://host/db_name"); mongoc_database_t *db = mongoc_client_get_default_database (client); assert (!strcmp ("db_name", mongoc_database_get_name (db))); mongoc_database_destroy (db); mongoc_client_destroy (client); /* no default database */ client = mongoc_client_new ("mongodb://host/"); db = mongoc_client_get_default_database (client); assert (!db); mongoc_client_destroy (client); .fi .B .SH COLOPHON This page is part of MongoDB C Driver. Please report any bugs at https://jira.mongodb.org/browse/CDRIVER.