BSON

BSON encoding/decoding, used in MongoDB drivers

image logotype/logo_32x32.png not found

BSON support

Implements BSON specification.

Synopsis

The main entry point is BSON::Document. This structure is a Hash like object but will keep the order of its keys and because of that there is no need for cumbersome operations. At the moment it is much slower than the hashed variant even with the encoding happening in the background and parallel.

use BSON::Document;

my BSON::Javascript $js .= new(:javascript('function(x){return x;}'));
my BSON::Javascript $js-scope .= new(
  :javascript('function(x){return x;}'),
  :scope(BSON::Document.new: (nn => 10, a1 => 2))
);

my BSON::Binary $bin .= new(:data(Buf,new(... some binary data ...));
my BSON::Regex $rex .= new( :regex('abc|def'), :options<is>);

my BSON::Document $d .= new: ( 'a number' => 10, 'some text' => 'bla die bla');
$d<oid> = BSON::ObjectId.new;
$d<javascript> = $js;
$d<js-scope> = $js-scope;
$d<datetime> = DateTime.now;
$d<bin> = $bin;
$d<rex> = $rex;
$d<null> = Any;
$d<array> = [ 10, 'abc', 345];
$d<subdoc1> = a1 => 10, bb => 11;
$d<subdoc1><b1> = q => 255;

my Buf $enc-doc = $d.encode;

my BSON::Document $new-doc .= new;
$new-doc.decode($enc-doc);

Documentation

BSON/Document.pod

Installing BSON

Use zef to install the package like so.

$ zef install BSON

When installing MongoDB, BSON will be installed automatically as a dependency.

Version of Raku and MoarVM

This module is tested using the latest 6.d Raku version on MoarVM

Authors

Original creator of the modules is Pawel Pabian (2011-2015, v0.3)(bbkr on github). Current maintainer Marcel Timmerman (2015-present)(MARTIMM on github).

Contributors

Dan Zwell (lefth on github)

BSON v0.13.3

BSON encoding/decoding, used in MongoDB drivers

Authors

  • Marcel Timmerman
  • Paweł Pabian

License

Artistic-2.0

Dependencies

OpenSSLUUIDMethod::Also

Test Dependencies

Provides

  • BSON
  • BSON::Binary
  • BSON::Decimal128
  • BSON::Decimal128::Actions
  • BSON::Decimal128::Grammar
  • BSON::Decode
  • BSON::Document
  • BSON::Encode
  • BSON::Javascript
  • BSON::ObjectId
  • BSON::Ordered
  • BSON::Regex

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.