Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
MONGOC_CLIENT_...FAULT_DATABASE(3)  libmongoc MONGOC_CLIENT_...FAULT_DATABASE(3)

SYNOPSIS
	mongoc_database_t *
	mongoc_client_get_default_database (mongoc_client_t *client);

     Get  the  database  named in the MongoDB connection URI, or 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.

PARAMETERS
     * client: A mongoc_client_t.

RETURNS
     A	 newly	 allocated   mongoc_database_t	 that	should	 be  freed  with
     mongoc_database_destroy().

EXAMPLE
     Default Database Example

	/* 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);

AUTHOR
     MongoDB, Inc

COPYRIGHT
     2009-present, MongoDB, Inc.

1.30.8				  Aug 27, 2026MONGOC_CLIENT_...FAULT_DATABASE(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=mongoc_client_get_default_database&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help