Skip to content

Commit

Permalink
DOCPS-41150: Specialized Data Formats + BSON (#19)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6bb165f)
  • Loading branch information
mcmorisi committed Jul 26, 2024
1 parent bfca20e commit a3b0643
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 6 deletions.
8 changes: 6 additions & 2 deletions snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ toc_landing_pages = [
"/read",
"/indexes",
"work-with-indexes",
"/data-formats"
]

[constants]
driver-long = "MongoDB Kotlin Sync Driver"
driver-short = "Kotlin Sync driver"
language = "Kotlin"
version-number = "5.1"
full-version = "{+version-number+}.2"
version = "v{+version-number+}"
patch-version-number = "{+version-number+}.0"
mdb-server = "MongoDB Server"
stable-api = "Stable API"
api = "https://mongodb.github.io/mongo-java-driver/{+version-number+}/apidocs/mongodb-driver-kotlin-sync"
api = "https://mongodb.github.io/mongo-java-driver/{+version-number+}/apidocs/mongodb-driver-kotlin-sync"
java-api = "https://mongodb.github.io/mongo-java-driver/{+version-number+}"
core-api = "{+java-api+}/apidocs/mongodb-driver-core/"
kotlin-docs = "https://kotlinlang.org"
42 changes: 42 additions & 0 deletions source/data-formats.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. _kotlin-sync-data-formats:

========================
Specialized Data Formats
========================

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

.. facet::
:name: genre
:values: reference

.. meta::
:keywords: bson, data, class, date, time

.. toctree::
:titlesonly:
:maxdepth: 1

/data-formats/bson

.. TODO: /data-formats/data-class
.. TODO: /data-formats/extended-json
.. TODO: /data-formats/time-series

Overview
--------

You can use several types of specialized document data formats in your {+driver-short+}
application. To learn how to work with these data formats, see the following
sections:

- Learn how to work with the BSON data format in the :ref:`BSON <kotlin-sync-bson>` guide.

.. TODO: Uncomment these as pages get built
.. - Learn how to store and retrieve data using {+language+} data classes in the :ref:`data-classes` guide.
.. - Learn how to use the Extended JSON format in the :ref:`kotlin-sync-extended-json` guide.
.. - Learn how to store and interact with time series data in the :ref:`kotlin-sync-time-series` guide.
89 changes: 89 additions & 0 deletions source/data-formats/bson.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. _kotlin-sync-bson:

==========================
Document Data Format: BSON
==========================

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

Overview
--------

In this guide, you can learn about the BSON data format, how MongoDB
uses BSON to organize and store data, and how to install the BSON library independently of
the {+driver-short+}.

BSON Data Format
----------------

**BSON**, or Binary JSON, is the data format that MongoDB uses to organize
and store data. This data format includes all JSON data structure types and
adds support for types including dates, differently-sized integers (32-bit and 64-bit),
ObjectIds, and binary data. For a complete list of supported types, see the
:manual:`BSON Types </reference/bson-types>` in the {+mdb-server+} documentation.

BSON is not human-readable, but you can use the
:ref:`BSON library <install-bson-library>` to convert it to the human-readable JSON
representation. You can read more about the relationship between these
formats in the :website:`JSON and BSON </json-and-bson>` guide on the MongoDB website.

MongoDB and BSON
----------------

You can work with BSON data in your {+driver-short+} application by using one of the
following object types that implements the `BSON interface <{+java-api+}/apidocs/bson/org/bson/conversions/Bson.html>`__:

- `Document <{+java-api+}/apidocs/bson/org/bson/Document.html>`__ (BSON library package)
- `BsonDocument <{+java-api+}/apidocs/bson/org/bson/BsonDocument.html>`__ (BSON library package)
- `RawBsonDocument <{+java-api+}/apidocs/bson/org/bson/RawBsonDocument.html>`__ (BSON library package)
- `JsonObject <{+java-api+}/apidocs/bson/org/bson/json/JsonObject.html>`__ (BSON library package)

.. _install-bson-library:

Install the BSON Library
------------------------

These instructions detail how to add the BSON library as a dependency to
your project.

.. note::

If you have already added the {+driver-short+} as a dependency to your
project, then you can skip this step. This is because the BSON library is already
included as a required dependency of the driver.

.. TODO: For instructions on how to add the
.. MongoDB Kotlin driver as a dependency to your project, see the
.. :ref:`driver installation <kotlin-sync-download-install>` section of our Get Started
.. guide.

We recommend that you use the `Maven <https://maven.apache.org/>`__ or
`Gradle <https://gradle.org/>`__ build automation tool to manage your {+language+}
project's dependencies. The following instructions detail the dependency declarations for
both Maven and Gradle:

.. tabs::

.. tab:: Maven
:tabid: maven-dependencies

The following snippet shows the dependency declaration in the
``dependencies`` section of your ``pom.xml`` file.

.. include:: /includes/data-formats/bson-maven-versioned.rst

.. tab:: Gradle
:tabid: gradle-dependencies

The following snippet shows the dependency declaration in the
``dependencies`` object in your ``build.gradle`` file.

.. include:: /includes/data-formats/bson-gradle-versioned.rst

If you are not using either of the preceding tools, then you can include the BSON dependency
in your project by downloading the JAR file directly from the
`sonatype repository <https://repo1.maven.org/maven2/org/mongodb/bson/>`__.
5 changes: 5 additions & 0 deletions source/includes/data-formats/bson-gradle-versioned.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. code-block:: kotlin
dependencies {
implementation("org.mongodb:bson:{+full-version+}")
}
9 changes: 9 additions & 0 deletions source/includes/data-formats/bson-maven-versioned.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. code-block:: xml
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>{+full-version+}</version>
</dependency>
</dependencies>
30 changes: 26 additions & 4 deletions source/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

.. toctree::

<<<<<<< HEAD
/read
=======
Get Started </get-started>
/connect
/write-operations
/read
/indexes
>>>>>>> 8920746 (DOCSP-41141: Indexes (#13))
/data-formats
/faq
/connection-troubleshooting
/issues-and-help
/compatibility
Validate Driver Artifact Signatures </validate-signatures>
View the Source <https://github.com/mongodb/mongo-java-driver/tree/master/driver-kotlin-sync>

Introduction
Expand Down Expand Up @@ -62,6 +62,28 @@ Quick Reference
See driver syntax examples for common MongoDB commands in the
:ref:`Quick Reference <kotlin-sync-quick-reference>` section.

Write Data to MongoDB
---------------------

Learn how you can write data to MongoDB in the :ref:`kotlin-sync-write` section.

Read Data from MongoDB
----------------------

Learn how you can retrieve data from MongoDB in the :ref:`kotlin-sync-read` section.

Optimize Queries with Indexes
-----------------------------

Learn how to work with common types of indexes in the :ref:`kotlin-sync-indexes`
section.

Specialized Data Formats
------------------------

Learn how to work with specialized data formats and custom types in the
:ref:`kotlin-sync-data-formats` section.

FAQ
---

Expand Down

0 comments on commit a3b0643

Please sign in to comment.