@@ -523,6 +523,10 @@ class MongoCollection
523
523
524
524
# Finds the first document that matches `query`.
525
525
#
526
+ # Params:
527
+ # * `skip` number of documents to skip
528
+ # * `limit` number of documents to return
529
+ #
526
530
# Returns `null` if an error occured. See `Sys::last_mongoc_error`.
527
531
#
528
532
# ~~~
@@ -533,9 +537,11 @@ class MongoCollection
533
537
# var doc = col.find(query)
534
538
# assert doc["foo"] == 10
535
539
# ~~~
536
- fun find (query : JsonObject ): nullable JsonObject do
540
+ fun find (query : JsonObject , skip , limit : nullable Int ): nullable JsonObject do
537
541
var q = new NativeBSON .from_json_string (query .to_json .to_cstring )
538
- var c = native .find (q )
542
+ var s = skip or else 0
543
+ var l = limit or else 0
544
+ var c = native .find (q , s , l )
539
545
q .destroy
540
546
if c == null then return null
541
547
var cursor = new MongoCursor (c )
@@ -549,16 +555,22 @@ class MongoCollection
549
555
550
556
# Finds all the documents matching the `query`.
551
557
#
558
+ # Params:
559
+ # * `skip` number of documents to skip
560
+ # * `limit` number of documents to return
561
+ #
552
562
# ~~~
553
563
# var client = new MongoClient("mongodb://localhost:27017/")
554
564
# var col = client.database("test").collection("test")
555
565
# var query = new JsonObject
556
566
# query["foo"] = 10
557
567
# assert col.find_all(query).length > 0
558
568
# ~~~
559
- fun find_all (query : JsonObject ): Array [JsonObject ] do
569
+ fun find_all (query : JsonObject , skip , limit : nullable Int ): Array [JsonObject ] do
570
+ var s = skip or else 0
571
+ var l = limit or else 0
560
572
var res = new Array [JsonObject ]
561
- var c = native .find (query .to_bson .native )
573
+ var c = native .find (query .to_bson .native , s , l )
562
574
if c == null then return res
563
575
var cursor = new MongoCursor (c )
564
576
while cursor .is_ok do
0 commit comments