How can i load data in IBM cloudant DB using node.js? - node.js

I am trying to create a survey using node.js+ejs and try to save data in cloudant DB but i am new with that so anyone knows how to do that ?

Your question is very open-ended; if you're not showing code, it's hard to give appropriate advice. Cloudant's official node library is very well documented. I'd suggest you start off with learning how you use that to store simple documents, and building from there onto storing your survey results.
See https://github.com/cloudant/nodejs-cloudant

Related

When should we use NodeJS and when should we use MongoDB?

As a new developer, I am always confused about using NodeJS and MongoDB. So I hope I will get an actual answer. Thanks...
MongoDB and NodeJS are two different technologies. MonogDB is a database system which gives you a chance to efficiently store documents in a database and to perform operations like data updates, or to search documents by some criterias.
NodeJS's responsibilty is especially to execute your application.
Nodejs is a Javascript engine that you can write any application you want with (by programming in the Javascript language). It runs your Javascript code. Most commonly, it is used to build servers that can respond to web requests, though it can be used for lots of other types of code too.
MongoDB is a database engine. Code within some application or server uses MongoDB to save, query or update data in a database. There are many web servers built with nodejs that will then use MongoDB for storing data.
MongoDB offers an API library that runs within a Nodejs application to give you programmatic access to MongoDB so you can create databases and then add, query, update or delete data from the MongoDB database. MongoDB also has API libraries for other programming environments such as Python, Java, etc...
These two technologies are for different parts of a typical web server system. You don't substitute one for the other. Instead, you can use them together.
When should we use Nodejs?
Any project needs a programming environment and a runtime library that offers you basic programming tools/support and can compile and/or interpret your code. Nodejs is such as tool for the Javascript programming language. There are other similar tools for other languages such as Python, Java, PHP, C#, C++, Go, etc...
So, if you want to write some kind of stand-alone program or server in Javascript, then you can use nodejs for it.
When should we use MongoDB?
If your application needs the ability to persistently store data in a way that you can efficiently query or update it later, then you would typically use some form of database. There are dozens of popular databases. MongoDB is one such database. MariaDB, MySql, CouchDB, DynamoDB (on AWS), Postgres are examples of other databases. Different databases have different strengths (things they are best at) and different ways of using them so it's a whole different question to choose the right/best database for what you're doing.
Here is a Blog link that will tell you when you should use NodeJS.
Here is another link to understand when you should use mongoDB.
Well, NodeJS and MongoDB are two different process. Here I tried to explain as simpler as possible:
NodeJS
Shortly we can say, NodeJS is a JavaScript runtime environment. It's actually helps JavaScript to run outside of server. It's used in server side development.
MongoDB
But, MongoDB is NoSQL database which is document oriented. It represents data as of JSON documents. It's used for store data.
Summary
The summary is MongoDB is a database where we can store data and NodeJS helps us to to connect our client site to database by it's server site.
Example:
Suppose you are building a website and you need a database to store the data or information so here you can use MongoDB but to be connected with MongoDB you need a connector, so here you can use NodeJS which will help your website to run outside of server.
Nodejs: Node.js is an interpreter or runtime/ running environment for JavaScript. built on Chrome's V8 JavaScript engine. responsibility is especially to execute your application.
MongoDB: is a No-SQL database for storing data. when you need high availability of data with automatic, fast, and instant data recovery.

PostgreSQL + Node Integration

Need some advice regarding the following situation:
There is an existing PostgreSQL database that I would like to draw information from (with full authorization of course). How can I query the entries in that database using NodeJS? I know sequelize can offer what I'm looking for, but I'm a bit confused as to how to approach this. I've heard that I would have to migrate the data first in order to then query it. What's the best way to go about doing this? Thanks.
For reference, I've taken a look at this link (https://github.com/sequelize/sequelize/issues/3791) but haven't gotten what I'd hoped out of it.
You can query without migration for existing database, this package should help https://www.npmjs.com/package/pg

Using dc.js with node.js

Is it possible to use dc.js with node.js, and if so how? I would like to provide an example, but it's hard to see how to start on this, and no working examples seem to be available online.
In short, yes.
I have implemented a full fledged app using nodejs and dc while the document store was mongo. The nodejs server is used for fetching the data from mongo db and serving it as api. Dc.js then uses this data for rendering charts.
I will write a blog post about it and post it in a couple of days. In the meantime do let me know if you have any more queries.
Updated:
Here is the link to the blog post.Do share if you find it useful.
https://anmolkoul.wordpress.com/2015/06/05/interactive-data-visualization-using-d3-js-dc-js-nodejs-and-mongodb/

How to structure database in mongoose for analytics

in my node.js app users are able to post downloadable content. Making them able to see how many downloads were performed is easy, but I'd like to create a dashboard for the users with a chart showing the downloads in a graph using d3.js). How to smartly structure my mongo database ? It should be flexible but small.
Take a look here. 10gen has made a real case for analytics with Mongo.
http://docs.mongodb.org/ecosystem/use-cases/pre-aggregated-reports/
http://www.mongodb.com/events/analytics-with-mongodb-dataversity

searching and retrieving data using node.js?

I was wondering is node.js good fit for searching massive amount of data, i know its main use is for asynchronous sceanrious like chat, ftp and real time etc. I was thinking of using node.js with mongodb to search 300,000 records of books for the library at my university, and see if it would oppose to using php & mysql. any advice would be great thanks.
Node.js would be a fine application interface for searching data .. but practically, so would PHP or many other languages :).
Your backend data storage solution (MySQL, MongoDB, ..) is a harder choice and really depends on the how you want to index and search the data.
If your main goal is search you probably want to look into a search application based on something like Apache Lucene. These typically use a relational database backend, although some newer efforts like ElasticSearch do have growing community support for ingesting data from sources like MongoDB (ref: MongoDB River Plugin for ElasticSearch).
Since you mentioned book search and libraries, you might also want to look into ILS (Integrated Library Search) applications which may already solve that problem. There are several open source products such as Koha and Evergreen.
Look at MongooseJS
Absolute perfect fit in my opinion.

Resources