Giter Site home page Giter Site logo

memento's Introduction

memento

FSO Part 13

Date: 22.03.2023 - 01.04.2023


CLI commands used

# Postgres
$ psql -U postgres

$ \du+ # list users

$ \l # list db's

$ \! clear # clear screen

# create user with login password
$ CREATE USER user WITH PASSWORD 'password';

# give role attributes to user to create DB
$ ALTER ROLE user CREATEDB;

# create db using the created user with role and grant privileges
$ psql postgres -U user
$ CREATE DATABSE db;
$ GRANT CONNECT ON DATABASE db TO user;
$ GRANT ALL PRIVILEGES ON DATABASE db TO user;

# create db and user with some privileges using postgres user 
$ psql -U postgres
$ CREATE USER user WITH PASSWORD 'password';
$ CREATE DATABASE db OWNER user;
$ GRANT CONNECT ON DATABASE db TO user;
$ GRANT ALL PRIVILEGES ON DATABASE db TO user;

# connect to db using user other than postgres
$ psql postgres -U user
$ \c dbname OR \conninfo dbname
$ \dt+ # show all tables in the current schema

# query db
$ psql -U postgres dbname
$ \dt
$ DROP TABLE "table_name"; # drop table on the current schema

# list tables of all schema
$ \dt *.*

# drop database outside the psql shell
$ dropdb dbname

# drop user
$ DROP OWNED BY user;
$ DROP USER user;

# display table data
$ \c dbname
$ Table "tablename";

# delete a row with condition
$ \c dbname
$ DELETE FROM "Blogs" WHERE id = 1;

# Sequelize

# generate/initialize db config dirs based on .sequilizerc using globally installed sequelize-cli
$ sequelize init

# create models and migrations with sequelize-cli
$ sequelize model:generate --name ModelName --attributes name:string,username:string,password:string

# adding new column to an existing table schema
$ sequelize migration:create --name name_of_the_migration_file
$ sequelize db:migrate


# migration to create db table
$ sequelize db:migrate

# API

# generate express app
$ express --view=ejs backend

# run backend dev server at port:8080
$ yarn run dev

# run production build at port:8080
$ yarn start

# format code
$ yarn prettier

# lint code
$ yarn eslint

memento's People

Contributors

aiotrope avatar

Watchers

 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.