diff --git a/META.info b/META.info index 34264b52..f4acf06e 100644 --- a/META.info +++ b/META.info @@ -36,5 +36,5 @@ "MongoDB": "lib/MongoDB.pm6" }, "source-url": "git://github.com/MARTIMM/mongo-perl6-driver.git", - "version": "v0.35.5.1" + "version": "v0.35.5.2" } diff --git a/README.md b/README.md index a65767ce..4de48f7d 100644 --- a/README.md +++ b/README.md @@ -213,8 +213,7 @@ and [Server Selection](https://www.mongodb.com/blog/post/server-selection-next-g There has been a lot of changes in the API. * All methods which had underscores ('\_') are converted to dashed ones ('-'). -* Many helper functions are removed. In the documentation must come some help to create a database/collection helper module as well as examples in the xt or doc directory. -* The way to get a database is changed. One doesn't use a connection for that anymore. +* Many helper functions are removed. In the documentation must come some help to create a database/collection helper module as well as examples in the xt or doc directory. In HL (higher level) there will come some modules which can be used. * Connection module is gone. The Client module has come in its place. ## Documentation @@ -225,10 +224,9 @@ There has been a lot of changes in the API. * [MongoDB](https://github.com/MARTIMM/mongo-perl6-driver/blob/master/doc/MongoDB.pdf) * [MongoDB::Client](https://github.com/MARTIMM/mongo-perl6-driver/blob/master/doc/Client.pdf) - -* doc/Database.pdf +* [MongoDB::Database](https://github.com/MARTIMM/mongo-perl6-driver/blob/master/doc/Database.pdf) * [MongoDB::Collection](https://github.com/MARTIMM/mongo-perl6-driver/blob/master/doc/Collection.pdf) -* doc/Cursor.pdf +* [MongoDB::Cursor](https://github.com/MARTIMM/mongo-perl6-driver/blob/master/doc/Cursor.pdf) * doc/Server.pdf * doc/Users.pdf diff --git a/doc/Cursor.pdf b/doc/Cursor.pdf new file mode 100644 index 00000000..e91b34aa Binary files /dev/null and b/doc/Cursor.pdf differ diff --git a/lib/MongoDB/Cursor.pod6 b/lib/MongoDB/Cursor.pod6 index 9010421d..7b650a78 100644 --- a/lib/MongoDB/Cursor.pod6 +++ b/lib/MongoDB/Cursor.pod6 @@ -1,78 +1,30 @@ -#!/usr/bin/env perl6 -# use v6.c; -# Running the pod file will create a pdf using wkhtmltopdf -# -my Str $pod = "$*PROGRAM"; -my Str $pdf = $pod; -$pdf ~~ s/\. <-[.]>+ $/.pdf/; -shell( "perl6 --doc=HTML '$pod' | wkhtmltopdf - '$pdf'"); - -#------------------------------------------------------------------------------- - =begin pod -=begin Xhtml - -=end Xhtml - =TITLE class MongoDB::Cursor =SUBTITLE Cursor to iterate a set of documents - package MongoDB { class Cursor does Iterable {...} } + unit package MongoDB; + class Cursor does Iterable {...} =head1 Synopsis - First example using find(). my MongoDB::Client $client .= new(:uri); my MongoDB::Database $database = $client.database('contacts'); my MongoDB::Collection $collection = $database.collection('perl_users'); - # Prepare array of documents with nonsensical data - # - my Array $docs = []; - for ^10 -> $i { - $docs.push: ( - code => 'd1' ~ $i.Str, - name => 'name and lastname', - address => 'address', - city => 'new york', - ); - } - - # Insert documents in cllection 'perl_users' - # - my BSON::Document $d = $database.run-command( - insert => $collection.name, - documents => $docs, - ); - is $d, 1, 'insert request ok'; - $d = $database.run-command: (count => $collection.name,); - is $d, 10, '10 documents found'; + if $d { say 'some docs available'; } - # Find everything - # + # Get the documents my MongoDB::Cursor $cursor = $collection.find; while $cursor.fetch -> BSON::Document $document { $document.perl.say; } + Second example using run-command to get information about collections $doc = $database.run-command: (listCollections => 1); @@ -148,12 +100,12 @@ same as used for the run-command returning the cursor information. method iterator ( ) -Method needed for the Iterable role placed on this Cursor class. I. Instead the following is possible; +Method needed for the Iterable role placed on this Cursor class. B> Instead the following is possible; for $collection.find -> BSON::Document $d { ... } -The method fetch() is used to get the next document. +The method fetch() is indirectly used to get the next document. =head2 fetch @@ -172,7 +124,7 @@ same document again. Delete the cursor when it is no longer needed. By default the server will delete the cursor after a non-usage period of 10 minutes. See also find() flags -described in Collection. The flag MongoDB::C-QF-NOCURSORTIMOUT for example will +described in Collection. The flag C-QF-NOCURSORTIMOUT for example will prevent the deletion of the cursor. =end pod diff --git a/lib/MongoDB/Database.pod6 b/lib/MongoDB/Database.pod6 index 631294fe..f200e0e0 100644 --- a/lib/MongoDB/Database.pod6 +++ b/lib/MongoDB/Database.pod6 @@ -6,7 +6,8 @@ use v6.c; =SUBTITLE Operations on a MongoDB database - package MongoDB { class Database { ... } } + unit package MongoDB; + class Database { ... } =head1 Synopsis