Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 159 lines (105 sloc) 3.791 kb
50685de @bbkr Markdown formatted read me added.
bbkr authored
1 # MongoDB Driver
2
3 ![Leaf](http://modules.perl6.org/logos/MongoDB.png)
4
7d90c6e @bbkr Bumped rakudo version info
bbkr authored
5 Requires [BSON 0.2+](https://github.com/bbkr/BSON).
76e820b @bbkr Spacing between 2nd level.
bbkr authored
6
7d90c6e @bbkr Bumped rakudo version info
bbkr authored
7 Compatible with Perl 6 [Rakudo Star](http://rakudo.org/) 2012.01+.
76e820b @bbkr Spacing between 2nd level.
bbkr authored
8
50685de @bbkr Markdown formatted read me added.
bbkr authored
9 ## SYNOPSIS
10
11 Let's see what it can do...
12
13 ### Initialize
14
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
15 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
16 use MongoDB;
17
18 my $connection = MongoDB::Connection.new( );
19 my $database = $connection.database( 'test' );
20 my $collection = $database.collection( 'perl_users' );
21 my $cursor;
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
22 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
23
24 ### Insert documents into collection
25
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
26 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
27 my %document1 = {
28 'name' => 'Paweł Pabian',
29 'nick' => 'bbkr',
30 'versions' => [ 5, 6 ],
31 'author' => {
32 'BSON' => 'https://github.com/bbkr/BSON',
33 'Integer::Tiny' => 'http://search.cpan.org/perldoc?Integer%3A%3ATiny',
34 },
35 'IRC' => True,
36 };
37
38 my %document2 = {
39 'name' => 'Andrzej Cholewiusz',
40 'nick' => 'andee',
41 'versions' => [ 5 ],
42 'IRC' => False,
43 };
44
45 $collection.insert( %document1, %document2 );
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
46 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
47
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
48 Flags:
071b182 @bbkr Fixed bullet formatting.
bbkr authored
49
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
50 * `:continue_on_errror` - Do not stop processing a bulk insert if one document fails.
50685de @bbkr Markdown formatted read me added.
bbkr authored
51
52 ### Find documents inside collection
53
54 Find everything.
55
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
56 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
57 my $cursor = $collection.find( );
58 while $cursor.fetch( ) -> %document {
59 %document.perl.say;
60 }
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
61 ````
50685de @bbkr Markdown formatted read me added.
bbkr authored
62
63 Or narrow down using condition.
64
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
65 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
66 $cursor = $collection.find( { 'nick' => 'bbkr' } );
67 $cursor.fetch( ).perl.say;
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
68 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
69
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
70 Options:
071b182 @bbkr Fixed bullet formatting.
bbkr authored
71
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
72 * `number_to_return` - Int - TODO doc
50685de @bbkr Markdown formatted read me added.
bbkr authored
73
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
74 Flags:
071b182 @bbkr Fixed bullet formatting.
bbkr authored
75
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
76 * `:no_cursor_timeout` - Do not time out idle cursor after an inactivity period.
50685de @bbkr Markdown formatted read me added.
bbkr authored
77
78 ### Update documents in collection
79
80 Update any document.
81
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
82 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
83 $collection.update( { }, { '$set' => { 'company' => 'Implix' } } );
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
84 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
85
86 Update specific document.
87
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
88 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
89 $collection.update( { 'nick' => 'andee' }, { '$push' => { 'versions' => 6 } } );
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
90 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
91
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
92 Flags:
071b182 @bbkr Fixed bullet formatting.
bbkr authored
93
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
94 * `:upsert` - Insert the supplied object into the collection if no matching document is found.
95 * `:multi_update` - Update all matching documents in the collection (only first matching document is updated by default).
50685de @bbkr Markdown formatted read me added.
bbkr authored
96
97 ### Remove documents from collection
98
99 Remove specific documents.
100
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
101 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
102 $collection.remove( { 'nick' => 'bbkr' } );
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
103 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
104
105 Remove all documents.
106
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
107 ```perl
50685de @bbkr Markdown formatted read me added.
bbkr authored
108 $collection.remove( );
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
109 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
110
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
111 Flags:
071b182 @bbkr Fixed bullet formatting.
bbkr authored
112
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
113 * `:single_remove` - Remove only the first matching document in the collection (all matching documents are removed by default).
50685de @bbkr Markdown formatted read me added.
bbkr authored
114
115 ## FLAGS
116
117 Flags are boolean values, false by default.
118 They can be used anywhere and in any order in methods.
119
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
120 ```perl
e260350 @bbkr Simplified flag explanation.
bbkr authored
121 remove( { 'nick' => 'bbkr' }, :single_remove );
122 remove( :single_remove, { 'nick' => 'bbkr' } ); # same
123 remove( single_remove => True, { 'nick' => 'bbkr' } ); # same
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
124 ```
50685de @bbkr Markdown formatted read me added.
bbkr authored
125
126 ## FEATURE ROADMAP
127
128 List of things you may expect in nearest future.
129
130 * Syntactic sugar for selecting without cursor (find_one).
131 * Error handler.
132 * Database authentication.
133 * Database or collection management (drop, create).
7d90c6e @bbkr Bumped rakudo version info
bbkr authored
134 * More stuff from [Mongo Driver requirements](http://www.mongodb.org/display/DOCS/Mongo+Driver+Requirements).
50685de @bbkr Markdown formatted read me added.
bbkr authored
135
136
137 ## KNOWN LIMITATIONS
138
139 * Big integers (int64).
140 * Lack of Num or Rat support, this is directly related to not yet specified pack/unpack in Perl6.
141 * Speed, protocol correctness and clear code are priorities for now.
142
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
143 ## CHANGELOG
144
145 * 0.4 - compatibility fixes for Rakudo Star 2012.02
146 * 0.3 - basic flags added to methods (upsert, multi_update, single_remove,...), kill support for cursor
147 * 0.2- adapted to Rakudo NOM 2011.09+.
148 * 0.1 - basic Proof-of-concept working on Rakudo 2011.07.
50685de @bbkr Markdown formatted read me added.
bbkr authored
149
29cb6d1 @bbkr Added license info.
bbkr authored
150 ##LICENSE
151
152 Released under [Artistic License 2.0](http://www.perlfoundation.org/artistic_license_2_0).
153
50685de @bbkr Markdown formatted read me added.
bbkr authored
154 ## CONTACT
155
071b182 @bbkr Fixed bullet formatting.
bbkr authored
156 You can find me (and many awesome people who helped me to develop this module)
38e43d9 @bbkr compatibility fixes for Rakudo Star 2012.02, reformatted readme with syn...
bbkr authored
157 on irc.freenode.net #perl6 channel as **bbkr**.
071b182 @bbkr Fixed bullet formatting.
bbkr authored
158
Something went wrong with that request. Please try again.