Read value from Cloudant NoSQLDB in Node-RED,IBM Bluemix

Q: How to read value from document in Cloudant NoSQLDB in Node-RED?

Document: document

Output: Riya Mary Roy ( Value of name)


Inject node configuration:


Cloudant node configuration:


Function node configuration:


Debug node configuration:


Output on the console:



Hashtag sentiment Analyzer using Node-RED,Cloudant, dashDB,R script


Twitter Node Configuration:7

Switch Node Configuration:


Not so positive function node configuration:


Positive sentiment Function Node configuration:


Cloudant Node Configuration:


Once after wiring the nodes, click on DEPLOY ( top right corner of Node-RED).

Launch Cloudant and then you will find your database in the list


Create a dashDB warehouse to graphically analyze the sentiment


Goto dashDB and then run R script



Data has been graphically analyzed using R Scripts.


1 represents Positive sentiment and 0 represents not-so-Positive sentiment


Web app using Java & Cloudant NoSQLDatabase in IBM Bluemix

IBM® Bluemix™ is the Platform as a Service(PaaS) cloud offering from IBM®. It enables organizations and developers to quickly and easily create, deploy, and manage applications on the cloud. Bluemix delivers enterprise-level services that can easily integrate with your cloud applications without you needing to know how to install or configure them.

IBM® Cloudant® NoSQL Database for Bluemix® is a NoSQL database as a service (DBaaS). It’s built from the ground up to scale globally, run non-stop, and handle a wide variety of data types like JSON, full-text, and geospatial. Cloudant NoSQL DB is an operational data store optimized to handle concurrent reads and writes, and provide high availability and data durability.

This tutorial will help you to build and deploy a java application that inserts registration details to Cloudant NoSQLDB


Let’s start building the java application,before that lets go to our Bluemix Catalog and select required services to build it!

Step 1: Goto Catalog and then click on Java Runtime


Step 2: Enter your application name. Eg: samplecloudant as shown in the image below. Click on CREATE

Step 3: Application has been created and it can be viewed on the Bluemix DASHBOARD. Click on the application

Step 4: Click on ADD SERVICE in the application(samplecloudant) DASHBOARD

Step 5: In CATALOG goto Data and Analytics and click on Cloudant NoSQL DB

Step 6: Change the Service name of Cloudant NoSQL DB to myCloudant and click on CREATE.

The service is now up and running in Bluemix! We can now proceed to Eclipse IDE to build the registration application that inserts details into Cloudant NoSQL Database.

We will be creating this web application using a Maven project in Eclipse(it is the easiest way to retrieve the dependencies we need — the ektorp client jars).

Step 7: Open Eclipse and create a new Maven project

Set the following values

  • Group ID: com.register
  • Artifact ID: registerblue
  • Version: 1
  • Packaging: war
  • Leave everything else as-is and Click Finish



Copy dependencies into pom.xml inside <project>


Create a servlet

  • Click on registerblue>src>main>java
  • Right click on register folder and then New > (Other) > Web > Servlet
  • Keep class name as RegisterServlet & package name as com and then click on Finish

In web.xml


In ( Resource Injection)

@Resource(name = “couchdb/myCloudant”)
protected CouchDbInstance mydb ;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

response.sendRedirect(request.getContextPath() + “/success.jsp”);

String name=request.getParameter(“name”);
String emailid = request.getParameter(“emailid”);
String mobile = request.getParameter(“mobile”);
String company=request.getParameter(“company”);
String loc=request.getParameter(“loc”);

String dbname = “registerdb”;
try {
//creates a database with the specified name
CouchDbConnector dbconnector = mydb.createConnector(dbname, true);
//create a document to place into your new database
Map<String, Object> doc = new HashMap<String, Object>();
doc.put(“_id”, UUID.randomUUID().toString());
doc.put(“name”, name);
doc.put(“emailid”, emailid);
doc.put(“mobile”, mobile);
doc.put(“company”, company);
doc.put(“location”, loc);

} catch (Exception e) {

Export the WAR file and push it into bluemix using Cloudfoundry command line interface.

Once the application has started,insert the details through registration page.

To view the inserted details,click on the Cloudant service that is bound to your application.

Click on LAUNCH, it will take you to database list,you can now find your database registerdb in the list.

Click on registerdb and then you can view your documents on the right side.

You can create a view in Design Documents section and then copy paste API URL(top right) to view the documents in the browserdetails

Courtesy:IBM Bluemix and Cloudant NoSQL DB!

Simple application using Node-RED Starter(SDK for Node js, Cloudant NoSQL database) in IBM Bluemix


IBM® Bluemix™ is the Platform as a Service(PaaS) cloud offering from IBM®. It enables organizations and developers to quickly and easily create, deploy, and manage applications on the cloud. Bluemix delivers enterprise-level services that can easily integrate with your cloud applications without you needing to know how to install or configure them. Bluemix provides a dashboard for you to create, view, and manage your applications and services as well as monitor your application’s resource usage. Bluemix dashboard also provides the ability to manage organizations, spaces, and user access.

Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.Node-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range nodes in the palette. Flows can be then deployed to the runtime in a single-click.JavaScript functions can be created within the editor using the a rich text editor.A built-in library allows you to save useful functions, templates or flows for re-use.

In IBM® Bluemix™, a boilerplate is a container for an application and its associated runtime environment and predefined services for a particular domain. You can use a boilerplate to quickly get up and running. The Node-RED Starter boilerplate has Node-RED,Cloudant databse and Monitoring and Analytics Services as a combo pack.You don’t have to spend time in adding or binding services.

The steps below will help you to build a simple twitter feed application and insert those tweets into Cloudant database with the Node-RED Starter boilerplate.


Step 1: Choose the Boilerplate Node-RED Starter from the CATALOG tab1.2

Step 2: Input the host name and click on CREATE


Step 3: Hurray! The application is created with Cloudant NoSQL DB and SDK for Node js


Step 4: One instance of the application is running perfectly! Click on the URL

blog3Step 5: Click on the button Go to your Node-RED flow editor


Step 6: The Node-RED page opens up with the nodes for each functionality on the left side


Step 7: Drag and drop the twitter node to the sheet1 (ensure you drag and drop the correct node)


Step 8: Double click on the twitter node and enter the required fields(ensure that you authenticate it with your twitter id) and click Oktwitter3Step 9: Drag and drop debug node in sheet 1


Step 10: Enter the required field as shown below


Step 11: Drag and drop cloudant node to sheet1(ensure that you have choosen the correct node)


Step 12: Double click the node and enter the required details


Step 13: Wire the nodes from its node points and click on DEPLOY


Step 14:Yes,now you can see live tweets for the hastag #bluemix on your debug console!!


Step 15: Goto the cloudant database


Step 16: Click on Launch


Step 17: You can see the database (tweets) ! Click on it. 


Step 18: You can see the documents with unique id and _rev


Step 19: Click on one of the document and you can see the tweet,date,time,created by whom and all other details in JSON format.


You can use the documents inserted in the Cloudant NoSQL database for further use and Yes,the application was ready within few minutes! That’s the power of Node-RED in IBM Bluemix. You can drag and drop other several nodes which are available in Node-RED to make this a better application(for analysis,for sending notifications etc)

Thanks to Node-Red,Cloudant NoSQL database and IBM Bluemix! You just saved our time from writing 1000 lines of code!

Courtesy: IBM Bluemix, Node-RED, Cloudant NoSQL Database