Skip to content

Commit

Permalink
Pod documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MARTIMM committed Nov 17, 2016
1 parent da02d96 commit c51f3e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 64 deletions.
2 changes: 1 addition & 1 deletion META.info
Expand Up @@ -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"
}
8 changes: 3 additions & 5 deletions README.md
Expand Up @@ -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
Expand All @@ -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

Expand Down
Binary file added doc/Cursor.pdf
Binary file not shown.
66 changes: 9 additions & 57 deletions 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
<style>
pre {
border-width: 2px;
border-style: solid;
border-color: #060;
padding: 10px 0 3px 10px;
color: #060;
background-color: #eaefea;
font-family: FreeMono;
}
td {
vertical-align: top;
}
</style>
=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<mongodb://>);
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<ok>, 1, 'insert request ok';
$d = $database.run-command: (count => $collection.name,);
is $d<n>, 10, '10 documents found';
if $d<n> { 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);
Expand Down Expand Up @@ -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<not to be
used directly>. Instead the following is possible;
Method needed for the Iterable role placed on this Cursor class. B<I<Not to be
used directly!>> 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
Expand All @@ -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
3 changes: 2 additions & 1 deletion lib/MongoDB/Database.pod6
Expand Up @@ -6,7 +6,8 @@ use v6.c;
=SUBTITLE Operations on a MongoDB database
package MongoDB { class Database { ... } }
unit package MongoDB;
class Database { ... }
=head1 Synopsis
Expand Down

0 comments on commit c51f3e7

Please sign in to comment.