Property definitions

mongodb $ NativeMongoClient :: defaultinit
# Wrapper for `mongoc_client_t`.
#
# `mongoc_client_t` is an opaque type that provides access to a MongoDB node,
# replica-set, or sharded-cluster.
# It maintains management of underlying sockets and routing to individual nodes.
#
# See [`mongoc_client_t`](http://api.mongodb.org/c/current/mongoc_client_t.html).
extern class NativeMongoClient `{ mongoc_client_t * `}

	# Wrapper for `mongoc_client_new()`.
	#
	# Creates a new `mongoc_client_t` using the `uri` string provided.
	new(uri: CString) `{
		mongoc_init();
		return mongoc_client_new(uri);
	`}

	# Wrapper for `mongoc_client_get_server_status()`.
	#
	# Queries the server for the current server status.
	# Returns `null` if an error occured.
	fun server_status: nullable NativeBSON import set_mongoc_error, NativeBSON.as nullable `{
		bson_error_t error;
		bson_t *reply = bson_new();
		if(!mongoc_client_get_server_status(self, NULL, reply, &error)){
			NativeMongoClient_set_mongoc_error(self, &error);
			return null_NativeBSON();
		}
		return NativeBSON_as_nullable(reply);
	`}

	# Wrapper for `mongoc_client_get_database_names()`.
	#
	# This function queries the MongoDB server for a list of known databases.
	# Returns `null` if an error occured.
	fun database_names: nullable NativeCStringArray
		import set_mongoc_error, NativeCStringArray, NativeCStringArray.as nullable `{
		bson_error_t error;
		char **strv;
		if((strv = mongoc_client_get_database_names(self, &error))) {
			return NativeCStringArray_as_nullable(strv);
		}
		NativeMongoClient_set_mongoc_error(self, &error);
		return null_NativeCStringArray();
	`}

	# Wrapper for `mongoc_client_destroy()`.
	#
	# This instance should not be used beyond this point!
	fun destroy `{
		mongoc_client_destroy(self);
		mongoc_cleanup();
	`}

	# Utility method to set `Sys.last_mongoc_error`.
	fun set_mongoc_error(err: BSONError) do sys.last_mongoc_error = err
end
lib/mongodb/native_mongodb.nit:158,1--214,3