Skip to main content

Create Micro CRUD services for Oracle Database Cloud using NodeJS

I will try to explain, how you can use NodeJS to create mirco services for the tables in your Oracle Database Cloud or on-premise Database.

Complete Github project :
You need to do "npm install" to download the node_modules.

Step by Step guide :

1. NodeJS : either 32 or 64 bit.

If you already have NodeJS installed, please check whether it is 64 or 32. Use below command to figure that out :
> require('os').arch()

If you get : 'ia32' , then it is 32 bit installation.

2. Install oracle-db node module

This was a lengthy and time consuming installation for me, because for Windows, it has a lot of pre-requisites. If you are a Mac user, you are lucky. :)
I followed :
There is also a detailed one in github :

3. Config your DB Cloud

Create a user and couple of tables on which we'll write the Microservices.
I created an user with some basic GRANTS


Connected to the DB instance via SQL Developer and created 2 tables :

Now we gonna write some CRUD services on both the tables.

4. Lets explain my NodeJS code

This tutorial from Oracle is excellent for starters :
You should go through it once before you try to understand my NodeJS construction.

JS code:
4i. app.js : Creates a NodeJS server and invokes "./routes/index.js" for REST URI "/" and "./routes/users.js" for URI "/users". All our DB cloud api is in "index.js"
4ii. ./routes/index.js : Defines an API catalogue on "/api/catalogue" and micro services on LEASE_HISTORY and USERS table.
4iii. ./routes/users_crud.js : Defines the CRUD methods for USERS table.
4iv. ./routes/lease_crud.js : Defines the CRUD methods for LEASE_HISTORY table.
4v.  ./routes/dbutil.js : Defines common utility methods for DB operations.

Config files:
4i. manifest.json : Defines the Application Container Cloud NodeJS version and command to start this NodeJS applicaiton. You only need this file if you want to deploy this application to Oracle Application Container Cloud, Otherwise not.
4ii. package.json : Defines application name, command and dependencies.

5. Running this locally:

Run it from command line :

Check in Postman :

6. Upload it in Application Container Cloud :

Follow the next blog on this.


  1. Developing better communication skills is important for every individual in society. It gives us the chance to express our thoughts and to share our own views about various aspects. It is also the source of building confidence.motivation letter for college


Post a Comment

Popular posts from this blog

Chatbots and Oracle Cloud Services

Thanks to Oracle A-Team, I had a chance to work with Chatbots.
3 pure NodeJS applications, on couple of Oracle Cloud platforms and Facebook messenger, and my chatbot was running.

Let me explain, the architecture a bit. To start with, following is the simple representation of how it works.

Exception Handling in ADF

This blog will give you an overview on how you can successfully deal with unhandled Runtime exceptions in an ADF application.

This will give you an idea of:
How to catch the unhandled exceptions.Write a separate log file with stacktrace and thread dumps.Redirect the user to an static error page
#1. Catch unhandled exceptions : 

Create a class "MyExceptionHandler" which extends : Override handleException() method.

public void handleException(FacesContext facesContext, Throwable throwable, PhaseId phaseId) throws Throwable {
        // this method is going to create a separate file with stacktrace and thread dumps
        // redirect to error page

 Create a folder "services" inside : ViewController\src\META-INF and then create a file named "".
In the file, add the absolute name of your custom e…

Bean Based ADF Table with List View in detailStamp facet

One of our projects, we had to display a "tree type" table with different datamodel for children. To solve this, I choose a normal af:table with a detailStamp facet with a List view inside it.
But pretty soon, I ran into an issue of correctly identifying the "disclosed" rows. Since my table's datasource is a bean, not ADF managed datacontrol.

So I solved it using a discloseListener on the af:table.

Full Application is on GitHub :

Classes invloved :

1. : dataProvider class for af:table
2. : dataProvider for the list view inside detailStamp of the table.
3. : provides the methods for populating af:table and af:listView. Also has a discloseListener method to correctly populate the listView datasource.

af:table definition :