GithubHelp home page GithubHelp logo

drruisseau / zio-sql-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sviezypan/zio-sql-example

0.0 1.0 0.0 57 KB

Simple app demonstrating web server that communicates with sql database using zio-sql library.

Scala 100.00%

zio-sql-example's Introduction

ZIO-SQL example application

Introduction

This repo contains a simple example application demonstrating how to use ZIO SQL to communicate with SQL database of your choice - I am using postgresql.

It's focused on ZIO SQL but contains also ZIO 2.0 best practices, ZIO HTTP endpoints and some other libraries from the ecosystem.

App exposes an http APIs that query and modify postgres db through CustomerRepository, OrderRepository and QueryService. Database contains customers and orders tables. Db schema and table content are loaded from src/main/resources/init.sql script.

Examples in repo include:

  1. selects
  2. inserts
  3. deletes
  4. joins
  5. subselects

To launch

  1. clone this repo
  2. cd zio-sql-example
  3. docker-compose up (you need to have docker running)
  4. sbt run
  5. example of requests:
    • GET localhost:8080/orders
    • GET localhost:8080/orders/count
    • GET localhost:8080/orders/04912093-cc2e-46ac-b64c-1bd7bb7758c3
    • GET localhost:8080/customers/
    • GET localhost:8080/customers/orders/join
    • GET localhost:8080/customers/orders/latest-date
    • GET localhost:8080/customers/orders/count
    • GET localhost:8080/customers/60b01fc9-c902-4468-8d49-3c0f989def37
    • POST localhost:8080/orders
{
    "id": "f02d8efb-d912-48f5-b7f8-ee6e589ab81e",
    "customerId":"bf356a10-9047-43e3-8df0-8935f0133eef",
    "date":"2022-03-25"
}
  • POST localhost:8080/customers
{
    "id": "6d90ce5b-55d4-4725-8c9f-9bb5c8104e62",
    "fname": "Ronald",
    "lname": "Russell",
    "verified": false,
    "dateOfBirth": "1965-01-05"
}

TODO

  1. add transactions example with ZTransaction datatype

zio-sql-example's People

Contributors

sviezypan 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.