On this page:
int32?
int64?
bson-document/  c
bson-sequence/  c
bson-min-key?
bson-min-key
bson-max-key?
bson-max-key
bson-null?
bson-null
bson-timestamp
bson-objectid?
new-bson-objectid
bson-objectid-timestamp
bson-javascript
bson-javascript/  scope
bson-binary
bson-regexp
2.1 Decoding Conventions

2 BSON

 (require net/bson) package: mongodb

MongoDB depends on BSON. This module contains an encoding of BSON values as Scheme values.

A BSON document is a dictionary that maps symbols to BSON values.

A BSON value is either

A BSON sequence is sequence of BSON values.

procedure

(int32? x)  boolean?

  x : any/c
A test for 32-bit integers.

procedure

(int64? x)  boolean?

  x : any/c
A test for 64-bit integers.
A contract for BSON documents.
A contract for BSON sequences.

A few BSON types do not have equivalents in Scheme.

procedure

(bson-min-key? x)  boolean?

  x : any/c
A test for bson-min-key.
The smallest BSON value.

procedure

(bson-max-key? x)  boolean?

  x : any/c
A test for bson-max-key.
The largest BSON value.

procedure

(bson-null? x)  boolean?

  x : any/c
A test for bson-null.
The missing BSON value.

struct

(struct bson-timestamp (value)
    #:extra-constructor-name make-bson-timestamp)
  value : int64?
A value representing an internal MongoDB type.

procedure

(bson-objectid? x)  boolean?

  x : any/c
A test for BSON ObjectIds, an internal MongoDB type.
Returns a fresh ObjectId.

procedure

(bson-objectid-timestamp oid)  exact-integer?

  oid : bson-objectid?
Returns the part of the ObjectID conventionally representing a timestamp.

A few BSON types have equivalents in Scheme, but because of additional tagging of them in BSON, we have to create structures to preserve the tagging.

struct

(struct bson-javascript (string)
    #:extra-constructor-name make-bson-javascript)
  string : string?
A value representing Javascript code.

struct

(struct bson-javascript/scope (string scope)
    #:extra-constructor-name make-bson-javascript/scope)
  string : string?
  scope : bson-document/c
A value representing Javascript code and its scope.

struct

(struct bson-binary (type bs)
    #:extra-constructor-name make-bson-binary)
  type : (symbols 'function 'binary 'uuid 'md5 'user-defined)
  bs : bytes?
A value representing binary data.

struct

(struct bson-regexp (pattern options)
    #:extra-constructor-name make-bson-regexp)
  pattern : string?
  options : string?
A value representing a regular expression.

2.1 Decoding Conventions

Only make-hasheq dictionaries are returned as BSON documents.

A bson-binary? where bson-binary-type is equal to 'binary is never returned. It is converted to bytes?.

Only vector sequences are returned as BSON sequences.