Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 56 lines (37 sloc) 1.518 kb
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
1 # BSON support
2
3 ![Face](http://modules.perl6.org/logos/BSON.png)
4
aa2f645 @bbkr Updated compatibility info
bbkr authored
5 Implements [BSON specification](http://bsonspec.org/).
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
6
aa2f645 @bbkr Updated compatibility info
bbkr authored
7 Compatible with Perl 6 [Rakudo Star](http://rakudo.org/) 2012.01+.
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
8
9
10 ## SYNOPSIS
11
aa2f645 @bbkr Updated compatibility info
bbkr authored
12 my $b = BSON.new;
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
13 my Buf $encoded = $b.encode(
14 {
15 "_id" => BSON::ObjectId.new( "4e4987edfed4c16f8a56ed1d" ),
16 "some string" => "foo",
17 "some number" => 123,
18 "some array" => [ ],
19 "some hash" => { },
20 "some bool" => Bool::True,
21 }
22 );
23 my $decoded = $b.decode( $encoded );
24
25
bf52bf1 @bbkr nicer formatting
bbkr authored
26 ### NATIVE TYPES
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
27
28 Perl6 <=> BSON
29
30 Str <=> UTF-8 string
31 Int <=> 32-bit Integer
32 Bool <=> Boolean "true" / "false"
33 Array <=> Array
34 Hash <=> Embedded document
35 BSON::ObjectId <=> ObjectId
36
37 `Rat`, `Real` - Not Yet Implemented
38
39
bf52bf1 @bbkr nicer formatting
bbkr authored
40 ### EXTENDED TYPES
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
41
aa2f645 @bbkr Updated compatibility info
bbkr authored
42 ```BSON::ObjectId``` - Internal representation is 12 bytes,
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
43 but to keep it consistent with MongoDB presentation described in
aa2f645 @bbkr Updated compatibility info
bbkr authored
44 [ObjectId spec](http://dochub.mongodb.org/core/objectids)
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
45 constructor accepts string containing 12 hex pairs:
46
47 BSON::ObjectId.new( '4e4987edfed4c16f8a56ed1d' )
48
aa2f645 @bbkr Updated compatibility info
bbkr authored
49 Internal ```Buf``` can be reached by `.Buf` accessor.
50 Method ```.perl``` is available for easy debug.
38c0c50 @bbkr Markdown formatted readme file.
bbkr authored
51
52
53 ## CONTACT
54
55 You can find me (and many awesome people who helped me to develop this module)
56 on irc.freenode.net #perl6 channel as __bbkr__.
Something went wrong with that request. Please try again.