Skip to content

kauppilainen/elixir-xtdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir+XTDB

This is an example project for Phoenix and XTDB. Once up and running head over to localhost:4000/trades to populate, view and update trades as well as play around with XT's bitemporal indices. This project is based on the Late Trade adjustments example at docs.xtdb.com

Run locally

To start your Phoenix server:

  • Start Phoenix Postgres and XTDB instance

    # Phoenix internal DB
    docker run -it --name phoenix-liveview --replace --pull=always -p 5433:5432 -e POSTGRES_PASSWORD=postgres -d postgres
    
    # XTDB
    docker run -it --rm --name phoenix-liveview-xtdb --pull=always -p 6543:3000 -p 5432:5432 ghcr.io/xtdb/xtdb
  • Run mix setup to install and setup dependencies

  • Run mix ecto.create to setup Phoenix DB

  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

You can now visit localhost:4000 from your browser.

Manually query XTDB using psql

# Connect
psql -h localhost -p 5432

Queries

# All trades up until now
SELECT *, _valid_from, _system_from FROM trades; 
# All trades up until '2024-01-15 20:00:00.000Z'
SELECT *, _valid_from, _system_from FROM trades FOR VALID_TIME AS OF TIMESTAMP '2024-01-15 20:00:00.000Z';

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published