Giter Site home page Giter Site logo

rust-api's Introduction

Database Notes

Docker setup

  • Pull image: docker pull postgres

  • Create persistent volume: docker volume create my_postgres_data

  • Run container: docker run --name my-postgres-container -e POSTGRES_PASSWORD=mysecretpassword -v my_postgres_data:/var/lib/postgresql/data -d postgres

  • Access the cli of the database in the container: docker exec -it my-postgres-container psql -U postgres

Database setup

  • Create: CREATE DATABASE mydatabase;

  • Connect: \c mydatabase

  • Create table: CREATE TABLE users ( id SERIAL PRIMARY KEY, username VARCHAR(50) UNIQUE NOT NULL, email VARCHAR(100) UNIQUE NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

  • Insert: INSERT INTO users (username, email) VALUES ('john_doe', '[email protected]');

  • Select: SELECT * FROM users;

To stop and remove container

docker stop my-postgres-container docker rm my-postgres-container

Remove all data

docker volume rm my_postgres_data

For some reason docker-compose not working.

TODOs

  • Tests
  • Abstractions (db controller layer)
  • Middleware (auth cookie, rate limit)
  • Restructure database for different tables

rust-api's People

Contributors

lach-g 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.