bson_t
.All data manipulated by mongoc
are BSON formated.
The bson_t
structure represents a BSON document.
This structure manages the underlying BSON encoded buffer.
For mutable documents, it can append new data to the document.
See bson_t
.
mongodb :: NativeBSON :: defaultinit
mongodb :: NativeBSON :: from_json_string
Wrapper forbson_new_from_json()
.
mongodb :: NativeBSON :: set_mongoc_error
Utility method to setSys.last_mongoc_error
.
mongodb $ NativeBSON :: 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 :: NativeBSON :: defaultinit
core :: Object :: defaultinit
core :: Pointer :: defaultinit
mongodb :: NativeBSON :: from_json_string
Wrapper forbson_new_from_json()
.
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.
core :: Object :: output_class_name
Display class name on stdout (debug only).mongodb :: NativeBSON :: set_mongoc_error
Utility method to setSys.last_mongoc_error
.
# Wrapper for `bson_t`.
#
# All data manipulated by `mongoc` are BSON formated.
#
# The `bson_t` structure represents a BSON document.
# This structure manages the underlying BSON encoded buffer.
# For mutable documents, it can append new data to the document.
#
# See [`bson_t`](http://api.mongodb.org/libbson/current/bson_t.html).
extern class NativeBSON `{ bson_t * `}
# Wrapper for `bson_new()`.
#
# The `bson_new()` function shall create a new `bson_t` structure on the heap.
# It should be freed with `bson_destroy()` when it is no longer in use.
new `{ return bson_new(); `}
# Wrapper for `bson_new_from_json()`.
#
# The `bson_new_from_json()` function allocates and initialize a new `bson_t`
# by parsing the JSON found in `data`.
# Only a single JSON object may exist in data or an error will be set and
# `NULL` returned.
new from_json_string(data: CString) import set_mongoc_error `{
bson_error_t error;
bson_t *bson;
bson = bson_new_from_json((uint8_t *)data, -1, &error);
if(!bson) {
NativeBSON_set_mongoc_error(bson, &error);
return NULL;
}
return bson;
`}
# Wrapper for `bson_as_json()`.
#
# The `bson_as_json()` function shall encode bson as a JSON encoded UTF-8 string.
# The caller is responsible for freeing the resulting UTF-8 encoded string
# by calling `bson_free()` with the result.
fun to_c_string: CString `{ return bson_as_json(self, NULL); `}
# Wrapper for `bson_destroy()`.
#
# The `bson_destroy()` function shall free an allocated `bson_t` structure.
# This function should always be called when you are done with a `bson_t`
# unless otherwise specified.
#
# This instance should not be used beyond this point!
fun destroy `{ bson_destroy(self); `}
# 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:28,1--80,3