NodeJS

NodeJS and MongoDB CRUD operations using Mongoose js library

If you are developing API or pages in NodeJS and Using the database MongoDb as storage, here is the example which gives you a getting started code to manage data in MongoDB database from NodeJs code. We will use MongooseJS library, which will work as a Database Layer to communicate with MongoDb. This library has all the required functionality for developing Production-ready applications. We are using ExpressJS to create the routes and to create server-side requests handler. 

Here, we are taking the example of books API where we want to create the CRUD operations.

Tags

NodeJS - Creating Module

Many times we uses modules in nodejs applications which comes from different package added in package.json file. This allows us to organize the code and to create reusable components.

Here are simple steps to create your own custom module.

Create a module file mymodule.js

exports.myServerTime = function () {
  return "Today is "+Date();
};

In the above code, you would notice a keyword "exports" which make properties and menthods of this module outside of this module file.