# satyaminfo_node_js_crud_mysql

> CRUD API With Validation In Node JS

Latest version **1.1.0** (published 2021-01-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install satyaminfo_node_js_crud_mysql
pnpm add satyaminfo_node_js_crud_mysql
yarn add satyaminfo_node_js_crud_mysql
bun add satyaminfo_node_js_crud_mysql
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-01-06 |
| First published | 2020-11-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Author | Satyam Vishwakarma |
| Maintainers | satyaminfo |
| Keywords | satyaminfo_node_js_crud_mysql, node_crud_mysql, node api make with validation, auto validation in node js, auto validation api, validation, satyaminfo |

## Links

- npm: https://www.npmjs.com/package/satyaminfo_node_js_crud_mysql
- npm.io page: https://npm.io/package/satyaminfo_node_js_crud_mysql

## Dependencies (6)

- [mysql](https://npm.io/package/mysql.md) ^2.18.1
- [colors](https://npm.io/package/colors.md) ^1.4.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [mysql2](https://npm.io/package/mysql2.md) ^2.2.5
- [sequelize](https://npm.io/package/sequelize.md) ^6.3.5
- [mysql-model](https://npm.io/package/mysql-model.md) 0.0.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-01-06
- 1.0.6 — 2020-11-06
- 1.0.5 — 2020-11-06
- 1.0.4 — 2020-11-06
- 1.0.3 — 2020-11-03
- 1.0.2 — 2020-11-03
- 1.0.1 — 2020-11-03
- 1.0.0 — 2020-11-03

## README

# satyaminfo CRUD in node.js useing mysql!

<img src="https://www.satyaminfo.in/public/images/si/logo/icon/Black_yellow.ico" 
alt="satyaminfo_node_js_crud_mysql" align="right"  height="150px"/>

This package is use to create [`CRUD API Operation`] in node js with [`API Validation`], this package is easy to use and operate also you can modify table or fields as per your requirement using the following step,
visit my website for my info [satyaminfo.in](https://satyaminfo.in)

## Install

```bash
# with npm
npm install satyaminfo_node_js_crud_mysql

# with npm 
npm install express mysql dotenv sequelize body-parser joi joi-objectid

```

## Usage

Create a `.env` file in the root directory of your project. Add
environment-specific variables on new lines in the form of `NAME=VALUE`.
For example:

```dosini
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=s!mpl3
DB_NAME=demo_db
```

Create a `config/config.js` file in the root directory of your project.

Your `config.js` file like this
```javascript

const mysql=require('mysql');
const dotenv=require('dotenv').config();
var con={
  host: process.env.DB_HOST,
  user:process.env.DB_USER,
  password:process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  dialect: "mysql",
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
};
var db_con=mysql.createConnection({
  host: process.env.DB_HOST,
  user:process.env.DB_USER,
  password:process.env.DB_PASSWORD,
  database: process.env.DB_NAME
});

module.exports.con=con;
module.exports.db_con=db_con;

```

Create a `crud_request/guest.js` file in the root directory of your project.

Your `guest.js` file is like this

```javascript
const {mysqlCrudNode}=require('satyaminfo_node_js_crud_mysql');
const {db_con} = require('../config/config');

mysqlCrudNode({
    table_name:'guest',
    table_fields:{
        name:'STRING',
        email:'STRING',
        password:'TEXT',
        phone:'INTEGER'
        },
    valid_fields:{
        name:"required|min:2|max:10|alphanum",
        email:"email|required",
        password:"required",
        phone:"required"
    },con:db_con
});

```

```bash
$ node crud_request/guest.js
```


Create a `server.js` file in the root directory of your project. for Run API Use On postman

Your `server.js` file is like this

```javascript
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const userRouter = require('./routes/api');

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
 
// parse application/json
app.use(bodyParser.json())

app.use('/api', userRouter);
const port=8081
app.listen(port, console.log(`server is listen on port ${port}`)); 

```
## Options

In this package 3 Options are there

* *table_name* here is your table name 
* *table_fields* here is your table fields name list
* *valid_fields* here is your table fields multiple vaidation list

---
_Source: https://npm.io/package/satyaminfo_node_js_crud_mysql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
