nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
readme: add information section
[nit.git]
/
lib
/
mongodb
/
native_mongodb.nit
diff --git
a/lib/mongodb/native_mongodb.nit
b/lib/mongodb/native_mongodb.nit
index
d25a9ac
..
fb8b305
100644
(file)
--- a/
lib/mongodb/native_mongodb.nit
+++ b/
lib/mongodb/native_mongodb.nit
@@
-421,11
+421,11
@@
extern class NativeMongoCollection `{ mongoc_collection_t * `}
#
# If you would like to specify options such as a sort order,
# the query must be placed inside of `{"$query": {}}`.
#
# If you would like to specify options such as a sort order,
# the query must be placed inside of `{"$query": {}}`.
- fun find(query: NativeBSON): nullable NativeMongoCursor import
+ fun find(query: NativeBSON, skip, limit: Int): nullable NativeMongoCursor import
NativeMongoCursor.as nullable, set_mongoc_error `{
bson_error_t error;
mongoc_cursor_t *cursor;
NativeMongoCursor.as nullable, set_mongoc_error `{
bson_error_t error;
mongoc_cursor_t *cursor;
- cursor = mongoc_collection_find(self, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
+ cursor = mongoc_collection_find(self, MONGOC_QUERY_NONE, skip, limit, 0, query, NULL, NULL);
if (mongoc_cursor_error(cursor, &error)) {
NativeMongoCollection_set_mongoc_error(self, &error);
return null_NativeMongoCursor();
if (mongoc_cursor_error(cursor, &error)) {
NativeMongoCollection_set_mongoc_error(self, &error);
return null_NativeMongoCursor();
@@
-506,7
+506,12
@@
extern class NativeMongoCursor `{ mongoc_cursor_t* `}
# Wrapper for `mongoc_cursor_current()`.
#
# Fetches the cursors current document or NULL if there has been an error.
# Wrapper for `mongoc_cursor_current()`.
#
# Fetches the cursors current document or NULL if there has been an error.
- fun current: NativeBSON `{ return (bson_t*) mongoc_cursor_current(self); `}
+ 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()`.
#
# Wrapper for `mongoc_cursor_next()`.
#
@@
-519,11
+524,6
@@
extern class NativeMongoCursor `{ mongoc_cursor_t* `}
return mongoc_cursor_next(self, &doc);
`}
return mongoc_cursor_next(self, &doc);
`}
- # Wrapper for `mongoc_cursor_more()`.
- #
- # This function shall indicate if there is more data to be read from the cursor.
- fun more: Bool `{ return mongoc_cursor_more(self); `}
-
# Wrapper for `mongoc_cursor_destroy()`.
#
# This instance should not be used beyond this point!
# Wrapper for `mongoc_cursor_destroy()`.
#
# This instance should not be used beyond this point!