Sequelize Sqlite3 cheat sheet

##Sequelize notes – ORM for Sqlite3, PostgreSql, MySQL and other

Install node packages:

npm install --save express body-parser sequelize sequelize-cli sqlite3 nodemon

Init dir structure:

node_modules/.bin/sequelize init

Create model and migration:

node_modules/.bin/sequelize model:generate --name Contact --attributes firstName:string,lastName:string,phone:string,email:string

Check the db:

$ sqlite3 database.sqlite3
SQLite version 3.20.1 2017-08-24 16:21:36
Enter ".help" for usage hints.
sqlite> .schema
CREATE TABLE `SequelizeMeta` (`name` VARCHAR(255) NOT NULL UNIQUE PRIMARY KEY);
CREATE TABLE `Contacts` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `firstName` VARCHAR(255), `lastName` VARCHAR(255), `phone` VARCHAR(255), `email` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
CREATE TABLE sqlite_sequence(name,seq);

Seed the db:

node_modules/.bin/sequelize db:seed:all

PostgreSQL cheat sheet

Ubuntu install lastest Postgres:

sudo apt-get install postgresql postgresql-contrib

Create user with password, admin and echo:

createuser -P -s -e <user_name>`

Check connection under localhost:

psql -h localhost -U <user_name> --password --dbname=postgres

then input password

Docker install on Ubuntu

This is based on the official documentation found in:
https://docs.docker.com/install/linux/docker-ce/ubuntu/

Uninstall old versions of Docker

$ sudo apt-get remove docker docker-engine docker.io containerd runc

Setup the repository

$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

$ sudo apt-get update

$ sudo apt-get install docker-ce docker-ce-cli containerd.io

$ sudo docker run hello-world

Post-install steps: sudo

$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ docker run hello-world
$ sudo systemctl enable docker