mongoc_cursor_t
.mongoc_cursor_t
provides access to a MongoDB query cursor.
It wraps up the wire protocol negotation required to initiate a query and
retreive an unknown number of documents.
Cursors are lazy, meaning that no network traffic occurs until the first call to mongoc_cursor_next().
At that point we can:
mongoc_cursor_next()
.mongoc_cursor_more()
.mongoc_cursor_current()
.See mongoc_cursor_t
.
mongodb :: NativeMongoCursor :: current
Wrapper formongoc_cursor_current()
.
mongodb $ NativeMongoCursor :: 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 :: NativeMongoCursor :: current
Wrapper formongoc_cursor_current()
.
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.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Wrapper for `mongoc_cursor_t`.
#
# `mongoc_cursor_t` provides access to a MongoDB query cursor.
# It wraps up the wire protocol negotation required to initiate a query and
# retreive an unknown number of documents.
#
# Cursors are lazy, meaning that no network traffic occurs until the first call
# to mongoc_cursor_next().
#
# At that point we can:
# * Retreive more records with repeated calls to `mongoc_cursor_next()`.
# * Test for more records with `mongoc_cursor_more()`.
# * Retrieve the document under the cursor with `mongoc_cursor_current()`.
#
# See [`mongoc_cursor_t`](http://api.mongodb.org/c/current/mongoc_cursor_t.html).
extern class NativeMongoCursor `{ mongoc_cursor_t* `}
# Wrapper for `mongoc_cursor_current()`.
#
# Fetches the cursors current document or NULL if there has been an error.
fun current: NativeBSON `{
// As said in documentation, BSON objects should not be freed manually.
bson_t* bson = (bson_t*) mongoc_cursor_current(self);
// Copy BSON so we can let the GC free it automatically.
return bson_copy(bson);
`}
# Wrapper for `mongoc_cursor_next()`.
#
# This function shall iterate the underlying cursor, setting `current` to the next
# document.
#
# This function is a blocking function.
fun next: Bool `{
const bson_t *doc;
return mongoc_cursor_next(self, &doc);
`}
# Wrapper for `mongoc_cursor_destroy()`.
#
# This instance should not be used beyond this point!
fun destroy `{ mongoc_cursor_destroy(self); `}
end
lib/mongodb/native_mongodb.nit:518,1--560,3