MongoDB Data Source

You can connect to MongoDB databases using the MongoDB data source.
lac42
You can connect to MongoDB databases using the MongoDB data source.
In this article:
3
Install the MongoDB JDBC Driver
  1. Get the MongoDB Java Driver (the MongoDB JDBC driver) from the MongoDB site.
    For more information about the version of the MongoDB driver that 
    CA Live API Creator
     supports, see Installation Requirements and Supported Platforms.
  2. Copy the 
    mongodb-driver-sync-<version>.jar
     JAR file (the MongoDB JDBC driver) into the directory that is based on the Java container on which you have installed 
    CA Live API Creator
    :
    The self-contained, single-user version of Live API Creator that is based on Jetty
    Copy the files into the 
    %JETTY_HOME%/caliveapicreator/lib/ext
     directory.
    Apache Tomcat
    Copy the files into the 
    %{CATALINA_HOME}/lib
     directory.
    Oracle WebLogic
    Copy the files into the 
    <Your WebLogic Domain Directory>/lib
     directory.
    JBoss/WildFly
    For more information, see Install on JBoss.
    IBM WebSphere
    Add the MongoDB JDBC driver into your Web application server.
    Using the WebSphere administrative console, create a JDBC provider for the driver in the server.
    For more information about how to create a JDBC provider, see the IBM WebSphere documentation.
  3. Restart API Server.
You have installed the MongoDB JDBC driver.
Connect to a MongoDB Database
You can connect to your MongoDB database using the following methods:
  • (If you have not created your API yet) When you create your API.
    For more information about how to create an API, see Creating APIs.
  • (If you have an existing API) By adding a connection to a MongoDB data source.
    For more information about how to add a connection to a data source, see Database Connectivity.
The following procedure details how to connect to your MongoDB database from an existing API by adding a connection to a MongoDB data source.
When you connect to a MongoDB database, you use the 
MongoDB
 data source provider as the data source. Data source providers are sets of JavaScript code that implement the extensible data source framework.
For more information about data source providers, see Manage Data Source Providers.
CA Live API Creator
 includes this data source provider.
Prerequisites:
  • You know your MongoDB connection information.
  • You have created your API and it is active.
    For more information about how to create an API, see Creating APIs.
Follow these steps:
  1. Open your API.
  2. In the Create section, click 
    Data Sources
    .
  3. Add a connection to a MongoDB database by completing the following steps:
    1. Click 
      Add
       above the list of data sources.
      The Create data source window opens.
    2. Complete the fields in the window, selecting 
      Data source provider
       from the 
      Create data source using
       drop-down and 
      MongoDB
       from the 
      Data source provider
       drop-down.
    For more information about how to add connections to databases, see Database Connectivity.
  4. Complete the 
    Hostname
    Port
    , and 
    Database Name
     fields.
  5. If your MongoDB database is secured with a username and password, complete the 
    Username
     and 
    Password
     fields.
  6. Select the 
    Active 
    checkbox to activate the data source.
  7. Save your changes.
You are connected to the MongoDB database.
MongoDB Supported Data Types
 
CA Live API Creator
 supports a subset of the full range of MongoDB data types. 
CA Live API Creator
 manipulates the MongoDB data that flows through it using the MongoDB API. In this way, 
CA Live API Creator
 supports all the BSON data types except 
Binary
.
Define Aliases or Exclude Attributes for MongoDB Table-Based Resources
When creating table-based resources and you are using the 
MongoDB
 data source provider as a data source, you can define aliases or exclude attributes for the collections that the MongoDB database returns by defining the extended properties for the resources.
For more information:
MongoDB Data Source Limitations 
Because this data source uses the extensible data source framework, there are known limitations to using the 
MongoDB
 data source provider as a data source. The following are known limitations.
Add Rules
When you are using the 
MongoDB
 data source provider as a data source, you can add only early event rule types, event rule types, and validation rule types.
For more information about the rule types that are available for you to add in API Creator, see Rule Types.
Call Table-Based Resources
When you are using the 
MongoDB
 data source provider as a data source, API users can call table-based resources only using the GET HTTP method.
Create Table-Based Subresources
When you are using the 
MongoDB
 data source provider as a data source and you are creating table-based subresources, you must join this subresource with the containing resource using API Creator even though you have defined a virtual relationship for the table.
For more information:
Enforce Security
When you are using the 
MongoDB
 data source provider as a data source, you cannot define specific role-level security for the entities that are exposed using this data source.
CA Live API Creator
 enforces security only at the REST endpoint.
MongoDB JDBC Driver Installed with Other JDBC Drivers
The MongoDB JDBC driver (the JAR file) and the Informix JDBC driver (the JAR file) reference different versions of the BSON library. These references conflict while running in 
CA Live API Creator
. You can install the MongoDB JDBC driver or the Informix JDBC driver, but you cannot have them installed simultaneously.
For more information about this known issue, see Release Notes.