Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wayou/node-crud

Node.js + Koa + MySQL CRUD example
https://github.com/wayou/node-crud

crud koa mysql node

Last synced: 3 months ago
JSON representation

Node.js + Koa + MySQL CRUD example

Awesome Lists containing this project

README

        

# koa + mysql todo app

sample project to demonstrate the crud operations.

## prerequirments

you need mysql installed and setup a appropriate user to run the demo.

### mysql quick reference

installing:

```sh
$ brew install mysql
```

start mysql service:

```sh
$ brew services start mysql
```

login as root and add a user:

```sh
$ mysql -uroot
mysql> create user ''@'localhost' identified with mysql_native_password by ''
```

then fill the `` and `pswd` into [config.js](./config.js)

login as the new created user and create corresponding database and tables.

```sh
mysql> quit
$ mysql -u -p
Enter password: ***
mysql> create database todo
mysql> use todo;
```

execute the following script to create the todo table:

```sh
CREATE TABLE `todo` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`content` varchar(500) COLLATE utf8mb4_general_ci DEFAULT NULL,
`is_done` int(11) DEFAULT '0',
`date` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
```

## installing

```sh
$ yarn
```

## running

```sh
$ yarn start
server started at http://localhost:3000
```

then visit [http://localhost:3000](http://localhost:3000).