The Oracle Database API for MongoDB (Mongo API for short) lets applications interact with collections of JSON documents in the Oracle Database using MongoDB commands.
Oracle Database understands Mongo-speak. That is the purpose of Oracle Database API for MongoDB.
Here is why and where you might use the MongoDB API:
You have one or more applications that interact with a MongoDB NoSQL database, and you want to migrate the data to an Oracle Database.
You have relatively simple collections of JSON documents and you prefer not to learn and use SQL.
You are used to and prefer to use MongoDB commands, particularly for the business logic of your applications (query by example) but also for data definition (creating collections and indexes), data manipulation (CRUD operations), and some database administration (status information).
If you have applications that use MongoDB, you’d like to make them more robust by providing advanced security; fully ACID transactions (atomicity, consistency, isolation, durability); standardized JOINs with all sorts of data; and analytics, machine-learning, and reporting capabilities.
With Oracle REST Data Services (ORDS), the Database API for MongoDB is now available for unmanaged Oracle Database on-premises as well as in the cloud as follows:
It can be installed against any Oracle Database 21c and 23ai
Any Autonomous Database, including ADB Serverless, ADB-Dedicated and ADB on Exadata Cloud@Customer, which all run Oracle Database 19c and above
Possibly any Oracle Database 19c with a very recent patch set (19.20->), but for that you need to talk to us
Customers on Autonomous database are able to configure their own unmanaged ORDS service with the Database API for MongoDB. With the latest release of Oracle Database 23ai, here is what has to be taken into account during the installation and configuration of ORDS for managed ORDS: Download the latest release of ORDS. As of August, 2024 – it is Version 24.2.3
Before you start you should ensure you have the following:
An Oracle Database 21c or later (as mentioned also 19.20 and above is doable)
Java version 11 or later
Knowledge of your TNS connection details for the database: this can either be Server/Port/Service name, or a TNS alias string
Knowledge of an administrative user with ‘as sysdba’ level access – normally SYS – and the password for that user
MongoDB client tools such as Mongo Shell or Compass installed somewhere to test the API
The instructions by Roger Ford listed here are still pretty much valid. Here are the steps for managed ORDS:
Step 1: Download ORDS
Step 2: Create Directories
Step 3: Unzip the ORDS download
Step 4: Set Environment Variables
Step 5: Run the ORDS installer
Step 6: Configure ORDS to enable MongoDB API
Step 7: Restart ORDS
Step 8: Configure a database user
Step 9 (Optional) Run Database Actions
Step 10: Configure Firewall
Detailed instructions on how to install Oracle Database 23ai, ORDS and Oracle APEX 24.1 on Oracle Cloud OEL with all steps written by Madhusudhan Rao can be found here. Check also the Oracle REST Data Services Installer Improvements for 24.1 by Jeff Smith here.
The Oracle Database API for MongoDB is described in detail in this 79 page document.
Here are 3 useful links related directly to the MongoDB API:
Overview of Oracle Database API for MongoDB
Develop Applications with Oracle Database API for MongoDB
Support for MongoDB APIs, Operations, and Data Types
Josh Spiegel wrote a blog post about the new 23.4 features of the MongoAPI. Here are the new MongoDB API features in Oracle Database 23ai described by Josh with some additional examples:
JSON collection tables:
– Now, it is possible to create JSON Collection Tables using SQL*Plus, SQL Developer, MongoDB Compass, mongosh and other compatible APIs
– The same JSON collections can be created, queried, dropped, updated from SQL*Plus, SQL Developer, etc., and several MongoDB clients:
SQL> CREATE JSON COLLECTION TABLE movies_content;
Table created.
Multi-value JSON indexes:
– Now, it is possible to create indexes from mongosh (see below) while in previous releases of Oracle Database, JSON indexes had to be created from SQL and the type of the data (string, number, date, etc.) had to be specified when the index was created
– Multi-value any-type indexes do not require users to specify a data type upfront, and they can be created directly from MongoDB clients
– And these indexes will be picked up by both MongoDB and SQL queries over the same data
External JSON Tables:
– The ORACLE_BIGDATA adapter for external tables can stream external JSON sources into the database making it easy and efficient query and load JSON stored in text files:
Aggregation Pipelines:
– In previous versions of Oracle Database, MongoDB aggregation pipelines were not supported, which sometimes created friction for users attempting to migrate MongoDB applications to Oracle Database
– In 23ai, these aggregation pipelines are now supported; they are transparently converted into SQL and executed directly
– We have also enhanced the aggregation framework by introducing a new stage that allows executing SQL directly from MongoDB connections: the $sql aggregation stage enables applications written against the Mongo API to access SQL without needing separate SQL connection pools to the database
JSON Duality views improvements and related tools:
– In 23.5, duality views are automatically accessible as JSON collections from the Mongo API
– In 23.5, the JSON to Duality Migrator automates migrations from MongoDB to Oracle
Client-side driver support for OSON:
Java (JDBC), Python, Node.js, and .NET drivers support encoding and decoding the OSON binary JSON format on the client-side
Read MoreJulian Dontcheff’s Database Blog