Contact Us

Contact Us



Pleas confirm by checkbox


Technical

Creating your first Node.js application with Node-Data

Author_img
By Suresh Dube December 13, 2017

In this blog, we will learn how to create a Node.js application with Node-Data. Let’s assume that you are building an application for blogs and you want to create REST APIs which can be used by a front-end/mobile application.

    • Create blogs into database
    • Update blogs into database
    • Delete blogs from database
    • Find and fetch a blog using any existing blog ID from the database

Prerequisites:

  • MongoDB is installed and server is running on a default port
  • Node 6.9.0 is installed
  • IDE (Eg: VS Code)
  • REST client (Eg: Postman, Curl) for testing

Installation:

  1. git clone https://github.com/ratneshsinghparihar/nodedata-demo-sample.git
  2. cd nodedata-demo-sample/Demo-Sample
  3. npm install

Code changes

  • Add a model blogmodel.ts inside the Models folder.
  • Add a repository blogmodelrepository.ts inside the Repositories folder.

[gist]6beea0b1a959769ff529d53203a9bc6d[/gist]

  • Model with @document to create a document inside Blogs collection.
  • A repository with the blog name will create all the necessary REST end points.

Testing

  1. npm start
  2. Post a JSON {“name”: “testBlog”} to http://localhost:9999/data/blogs
  3. Hit the api to get data(http://localhost:9999/data/blogs)
  4. Hit the api with put method http://localhost:9999/data/blogs/{{blogId}} with body {“name”: “testBlog1”}
  5. Hit the api with delete method http://localhost:9999/data/blogs/{{blogId}}

Conclusion

Now you can see how creating rest apis is super easy with node-data. If you want to know more check out the our github
 
https://github.com/ratneshsinghparihar/Node-Data

Or visit our main page

https://nodedataio.azurewebsites.net/

Related posts
3 Crucial Ways of Inserting Code into a Running Application without Creating Bottlenecks
Technical

3 Crucial Ways of Inserting Code into a Running Application without Creating Bottlenecks

By sureshdube January 28, 2022
Apache Spark Standalone Setup On Linux/macOS
Technical

Apache Spark Standalone Setup On Linux/macOS

By sureshdube October 20, 2021
Apache Flink Standalone Setup on Linux/macOS
Technical

Apache Flink Standalone Setup on Linux/macOS

By sureshdube October 13, 2021
Identity, Authentication, And Access Management Using Azure Active Directory  
Technical

Identity, Authentication, And Access Management Using Azure Active Directory  

By sureshdube September 22, 2021
Things to Know Before You Select A Crypto Wallet
Blockchain

Things to Know Before You Select A Crypto Wallet

By sureshdube September 20, 2021
Solve 3 Most Irritating Outlook Email Rendering Issues.
Technical

Solve 3 Most Irritating Outlook Email Rendering Issues.

By sureshdube September 15, 2021
Intuit Wasabi – A Scalable A/B Testing Solution
Technical

Intuit Wasabi – A Scalable A/B Testing Solution

By sureshdube September 01, 2021
How To Pick The Right Data Analytics Strategy For Serverless Systems?
Big Data

How To Pick The Right Data Analytics Strategy For Serverless Systems?

By sureshdube August 25, 2021
Change Notifications and Named Options using Options pattern in .NET Core
Technical

Change Notifications and Named Options using Options pattern in .NET Core

By sureshdube August 18, 2021
Create Strongly Typed Configurations in .NET Core
Technical

Create Strongly Typed Configurations in .NET Core

By sureshdube August 13, 2021

Stay updated

Get the latest creative news from Fubiz about art, design and pop-culture.