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
.
mongodb :: NativeMongoClient :: database_names
Wrapper formongoc_client_get_database_names()
.
mongodb :: NativeMongoClient :: new
Wrapper formongoc_client_new()
.
mongodb :: NativeMongoClient :: server_status
Wrapper formongoc_client_get_server_status()
.
mongodb :: NativeMongoClient :: set_mongoc_error
Utility method to setSys.last_mongoc_error
.
mongodb $ NativeMongoClient :: SELF
Type of this instance, automatically specialized in every classcore :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
mongodb :: NativeMongoClient :: database_names
Wrapper formongoc_client_get_database_names()
.
core :: Pointer :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
mongodb :: NativeMongoClient :: new
Wrapper formongoc_client_new()
.
core :: Object :: output_class_name
Display class name on stdout (debug only).mongodb :: NativeMongoClient :: server_status
Wrapper formongoc_client_get_server_status()
.
mongodb :: NativeMongoClient :: set_mongoc_error
Utility method to setSys.last_mongoc_error
.
# 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