8 Using Oracle Database API for MongoDB
Oracle Database API for MongoDB makes it possible to connect to Oracle Autonomous Database using MongoDB language drivers and tools.
Oracle Database API for MongoDB leverages the converged database capabilities of an Autonomous Database to manage multiple data types, including JSON data, within a single database. For example, these converged database capabilities allow you to use SQL to query or update JSON data.
See Oracle Database API for MongoDB for more information.
See About Autonomous JSON Database for more information.
See About Autonomous Database for Transaction Processing and Mixed Workloads for more information.
Configure Access for MongoDB
Oracle Database API for MongoDB enables you to use an Oracle Autonomous Database as the data store. You can create and configure a new Autonomous Database or modify the configuration of an existing Autonomous Database.
Configure a New Autonomous Database for MongoDB
Follow the steps in Provision an Autonomous Database, up to the point where you select your Network Access Type.

Description of the illustration adb_network_access_acl_provision.png
Configure an Existing Autonomous Database for MongoDB
Open the Oracle Cloud Infrastructure Console for your Autonomous Database instance.

Description of the illustration ajd_modification_for_new_mongodb_use.png
In the Network section, next to Access Control List click the Edit link.
Note for setting the Network Access Type:
- If your database Network Access Type is Private endpoint access only, you first must change to Allow secure access from everywhere using the Update Network Access from More Actions list in the Oracle Cloud Infrastructure Console. When switching to Allow secure access from everywhere, you will not be able to set the ACLs. After you change the network type, you can edit the ACLs.
Access Control List (ACL) Setup
See Configure Access Control Lists for an Existing Autonomous Database Instance for more information.
-
In the choose network access area, click Add My IP Address. This copies your IP address into the Values field.
- After disabling any VPN, use the WhatIsMyIP website.
- After disabling any VPN, use the curl command:
curl -s https://ifconfig.me
.
Note:
Public IP addresses may change. Any change to your public IP address will require a change in the ACL. If you are unable to access your database, your ACL should be something you check.ACLs Types and Use Cases
ACL Type | Use Case | Comment |
---|---|---|
IP Address | Local development laptops sharing the same public IP address | Easiest way to get started. Any laptop connected on this LAN will have access to the database with the database credentials. |
CIDR Block | Local development laptop | Using IPv4/32 notation |
IP Addresses separated by commas | Small number of local development laptops connected on distinct LANs (having distinct public IP addresses) | Can be tedious to manage with 10+ laptops. |
CIDR Block | Local development laptops connected on the same subnet exposed to Internet (each laptop has its own public IP Address) | Rely on CIDR Block notation. See calculator here for more information. Example: 89.84.109.0/24 gives 256 possible IP addresses from 89.84.109.0 to 89.84.109.255 |
VCN with CIDR Block | For testing, production, or CI/CD pipeline hosted on OCI having their own VCN and Compute instances | Assign OCI compartment per environment type. |
Mixing IP Address and VCN with CIDR Block | Local development laptop accessing a test Autonomous Database with connections from the testing environment or CI/CD pipeline | A common configuration option for on-going development work. |
User Management for MongoDB
Oracle Database API for MongoDB enables you to use an Oracle Autonomous Database as the data store. If you want or need to use an existing Autonomous Database for this purpose, here is the workflow.
Oracle Database API for MongoDB enables the mapping of Autonomous Database objects to MongoDB objects as follows:
MongoDB Object | Oracle Autonomous Database Object |
---|---|
database | schema |
collection | table |
document | document (in a column) |
For example, you could create a collection using the Oracle Database API for MongoDB as follows:
use scott;
db.createCollection('fruit');
A table named FRUIT is created in the schema SCOTT.
When you connect to the Oracle Database API for MongoDB, you authenticate using an Autonomous Database username and password. This authenticated connection then accesses collections within the corresponding schema. This user must meet the following requirements:
- The user's schema must be ORDS-enabled, which is sometimes referred to as enabled for Web Access. See Basic Setup to Enable ORDS Database API for more information.
- The user must have the following roles and privileges:
SODA_APP
,CREATE TABLE
, andCREATE SESSION
. See Manage User Roles and Privileges on Autonomous Database for more information. - The user has a quota on tablespace DATA. See Create Users on Autonomous Database for more information.
Note:
The roleDWROLE
in the Autonomous Database contains these roles, among others.
Access to schemas not granted to the user is prohibited. For example, the user SCOTT can only access collections in the schema SCOTT. There is one exception. If the authenticated user has the Autonomous Database privileges CREATE USER
, ALTER USER
and DROP USER
, that user can access any ORDS-enabled schema.
Additionally, a user with these privileges can implicitly create schemas. That is, when the user creates a collection in a database that does not exist, the schema will be created automatically. See Oracle Database API for MongoDB for more information.
Create a Test Autonomous Database User for MongoDB
Connect MongoDB Applications to Autonomous Database
Connecting your MongoDB application to Autonomous Database includes several steps, depending upon your requirements.