GithubHelp home page GithubHelp logo

b19_mysql's Introduction

B19_MYSQL

This is a simple API that saves personal notes in a MYSQL database.

To run the API execute following commands.

npm install
npm start

To run tests

npm test
Database

Create database and table for perform crud operation of node js restful API.

CREATE TABLE Note (
    NoteId int NOT NULL AUTO_INCREMENT,
    NoteHeading varchar(255) NOT NULL,
    NoteContent varchar(255),
    IsArchived boolean,
    PRIMARY KEY (NoteId)
)
Database Connection Details

Required database connection for fetching or update data into database is as follows.

When establishing a connection, you can set the following options:

host: The hostname of the database you are connecting to. (Default: localhost) user: The MySQL user to authenticate as. password: The password of that MySQL user. database: Name of the database to use for this connection (Optional).

There is a db connection wrapper, this will allow you to create connection on db which stored on a single file and can be reuse by other modules.To create database connection in dbConnection.js include following code.

var mysql=require('mysql')

var dbConn = mysql.createConnection({
    host: '',
    user: '',
    password: '',
    database: ''
});
dbConn.connect();

module.exports = dbConn;

API

                        localhost:3000/notes/

API Methods

  • /notes/addNew - Accepts a POST request and Create a new Note in the database.
  • /notes/- Aceept a GET request and Fetch all the Notes details from the database.
  • /notes/:id- Aceept a GET request and Returns a single Note record.
  • /notes/update - Aceept a PUT request and Update a Note. Only Note Heading and the Note Content.
  • /notes/delete/:id-Aceept a DELETE request andDelete a Note.

b19_mysql's People

Contributors

chameerad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.