I’m pleased to announce version 1.7.0 of libbson and libmongoc, the libraries constituting the MongoDB C Driver.

The main new features are an updated JSON-BSON codec, more resilient network layer, and convenient linking.

libbson

New features and bug fixes:

  • Changes to JSON encoding and decoding:
  • New functions bson_as_canonical_extended_json and bson_as_relaxed_extended_json convert BSON to canonical and relaxed extended JSON according to MongoDB Extended JSON Spec. Output for the existing bson_as_json function has not been changed.
  • When parsing JSON type wrappers like “$timestamp”, any missing or extra keys are an error.
  • The JSON format for BSON regular expressions is now “$regularExpression”: {“pattern”: “…”, “options”: “…"}. The old format {"$regex”: “…”, “$options”: “…"} is still parsed.
  • The JSON format for BSON binary elements is now “$binary”: {“base64”: “…”, “subType”: “…"}. The old format {"$binary”: “…”, “$type”: “…"} is still parsed.
  • BSON dates can be parsed from “$date” as an ISO8601 date or “$numberLong” as milliseconds since the epoch: “t”: {"$date”: {"$numberLong”: “1234”}}. Dates can no longer be formatted as raw integers. bson_as_json writes a BSON date after 1970 as “$date” with an ISO8601 string, and dates before 1970 as negative milliseconds wrapped in “$numberLong”. bson_as_canonical_extended_json always writes dates with “$numberLong”. bson_as_relaxed_extended_json always writes dates with “$date”.
  • The non-numbers NaN, Infinity, and -Infinity are now recognized (regardless of case) when parsing JSON.
  • CMake build now installs .pc files for programs that link to libbson using pkg-config. Both the CMake and Autotools build systems now install .cmake files for programs that link to libbson using CMake. Linking to libbson statically or dynamically is now much more convenient.
  • New CMake option, “ENABLE_STATIC”, defaults to ON.
  • Minimum required CMake version has been increased to 3.1.
  • CMake remains experimental on non-Windows platforms and issues a warning now
  • New functions
  • bson_strcasecmp, a portable equivalent of strcasecmp.
  • bson_iter_as_double, cast the current value to double.
  • bson_iter_init_from_data, creates an iterator from BSON string.
  • bson_validate_with_error, checks a document like bson_validate does but also reports which key was invalid
  • New convenience macros
  • BSON_ITER_HOLDS_INT, checks if iterator holds int32 or int64
  • BSON_ITER_HOLDS_NUMBER, checks if iterator holds int32, int64 or double
  • Raised BSON recursion limit to 200

libmongoc

New features and bug fixes:

  • CMake build now installs .pc files for programs that link to libmongoc using pkg-config. Both the CMake and Autotools build systems now install .cmake files for programs that link to libmongoc using CMake. Linking to libmongoc statically or dynamically is now much more convenient. See the new tutorial section “Include and link libmongoc in your C program”.
  • New CMake option ENABLE_STATIC can be ON, OFF, or AUTO (the default)
  • Minimum required CMake version has been increased to 3.1.
  • CMake remains experimental on non-Windows platforms and issues a warning now
  • Support for wire compression.
  • Support for snappy and zlib. MongoDB 3.4 only supports snappy, while zlib support is expected in MongoDB 3.6. The enable, configure mongoc like so: ./configure --with-snappy --with-zlib
  • New functions: mongoc_uri_get_compressors and mongoc_uri_set_compressors, to get and set compressor configuration on mongoc_uri_t
  • Added support for comma seperated “compressors” connection string option (e.g. mongodb://localhost/?compressors=snappy,zlib)
  • Added support for configuring zlib compression level in the connection string (e.g. mongodb://localhost/?compressors=zlib&zlibcompressionlevel=8)
  • Now requires the use of CMake config files for libbson to build libmongoc with CMake
  • Added pkg-config support for libressl.
  • New function mongoc_uri_set_auth_mechanism to update the authentication mechanism of a mongoc_uri_t after it is created from a string.
  • New function mongoc_bulk_operation_insert_with_opts provides immediate error checking.
  • New function mongoc_uri_new_with_error provides a way to parse a connection string, and retrieve the failure reason, if any.
  • Support for MongoDB Connection String specification
  • All connection string options are now represented by MONGOC_URI_xxx macros
  • Paths to Unix Domain Sockets must be url encoded
  • Repeated options now issue warnings
  • Special characters in username, password and other values must be url encoded
  • Unsupported connection string options now issue warnings
  • Boolean values can now be represented as true/yes/y/t/1 and false/no/n/f/0.
  • Case is now preserved in Unix domain paths.
  • New function mongoc_cursor_error_document provides access to server’s error reply if a query or command fails.
  • New function mongoc_write_concern_is_default determines whether any write concern options have been set, and mongoc_read_concern_is_default checks if read concern options are set.
  • mongoc_gridfs_find_one_with_opts optimized to use limit 1.

Links:

Thanks to everyone who contributed to this release.

  • Hannes Magnusson
  • A. Jesse Jiryu Davis
  • David Golden
  • Jeremy Mikola
  • Bernard Spil
  • Aleksander Melnikov
  • Adam Seering
  • Remi Collet
  • gael Magnan
  • Hannes Magn?sson
  • David Carlier
  • Paul Melnikow
  • Petr Písař
  • Shane Harvey
  • alexeyvo
  • Greg Rowe

Peace,
  — A. Jesse Jiryu Davis


Image: United States Mail steamship Arctic (launched 1850). Lithograph by N. Currier.