Node js
Published: 2021-12-23 17:02:27

**1.What are NoSQL databases? What are the different types of NoSQL databases?**
Ans :  A NoSQL database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases (like SQL, Oracle, etc.).
Types of NoSQL databases:
Document Oriented
Key Value
Graph
Column Oriented
**2.What kind of NoSQL database MongoDB is?**

Ans : MongoDB is a document oriented database. It stores data in the form of BSON structure based documents. These documents are stored in a collection.

**3.Which are the most important features of MongoDB?**
Ans : 

Flexible data model in form of documents
Agile and highly scalable database
Faster than traditional databases
Expressive query language

**4.Which all languages can be used with MongoDB?**

Ans : Currently, MongoDB provides official driver support for C, C++, C#, Java, Node.js, Perl, PHP, Python, Ruby, Scala, Go and Erlang. MongoDB can easily be used with any of these languages. There are some other community supported drivers too but the above mentioned ones are officially provided by MongoDB.

**5.Compare SQL databases and MongoDB at a high level.**

Ans : SQL databases store data in form of tables, rows, columns and records. This data is stored in a pre-defined data model which is not very much flexible for today's real-world highly growing applications. MongoDB in contrast uses a flexible structure which can be easily modified and extended.
**
6.How is MongoDB better than other SQL databases?**
Ans : MongoDB allows a highly flexible and scalable document structure. For e.g. one data document in MongoDB can have five columns and the other one in the same collection can have ten columns. Also, MongoDB databases are faster as compared to SQL databases due to efficient indexing and storage techniques.

**7.Can you run multiple Javascript operations in a single mongod instance?**

Ans : Yes. The V8 JavaScript engine added in 2.4 allows multiple JavaScript operations to run at the same time.

**8.Can one MongoDB operation lock more than one database? If yes, how?**
Ans : Yes. Operations like copyDatabase(), repairDatabase(), etc. can lock more than one database involved.

**9.Why use Node.js?**
Ans : Node.js makes building scalable network programs easy. Some of its advantages include:
It is generally fast
It rarely blocks
It offers a unified programming language and data type
Everything is asynchronous 
It yields great concurrency
**10.Why is Node.js Single-threaded?**
Ans : Node.js is single-threaded for async processing. By doing async processing on a single-thread under typical web loads, more performance and scalability can be achieved instead of the typical thread-based implementation.

**11.If Node.js is single-threaded, then how does it handle concurrency?**
Ans : The Multi-Threaded Request/Response Stateless Model is not followed by the Node JS Platform, and it adheres to the Single-Threaded Event Loop Model. The Node JS Processing paradigm is heavily influenced by the JavaScript Event-based model and the JavaScript callback system. As a result, Node.js can easily manage more concurrent client requests. The event loop is the processing model's beating heart in Node.js.
**12. Explain callback in Node.js.**
Ans : A callback function is called after a given task. It allows other code to be run in the meantime and prevents any blocking.  Being an asynchronous platform, Node.js heavily relies on callback. All APIs of Node are written to support callbacks.
**13. What are the advantages of using promises instead of callbacks?**
Ans : 
The control flow of asynchronous logic is more specified and structured.
The coupling is low.
We've built-in error handling.
Improved readability.
**14. How is Node.js most frequently used?**
Ans : Node.js is widely used in the following applications:
Real-time chats
Internet of Things
Complex SPAs (Single-Page Applications)
Real-time collaboration tools
Streaming applications
Microservices architecture