Skip to content

arnaudgeiser/sortable-clj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sortable

A small experiment to prove sortable problem can be solve easily with just a little bit of SQL

Prerequisite

Run

# Start PostgreSQL
docker run --rm --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=pass -d postgres

# Run the HTTP server
lein run

Experiment

Generate 20 ordered items

curl -X PUT localhost:8080/items/reset/20

Get all the items

curl localhost:8080/items

Remove an item in the middle

curl -X PUT localhost:8080/items -H "Content-Type: application/json" -d '{"deleted": [10]}"'
10 # => 10 rows affected

Insert a new item at the end

curl -X PUT localhost:8080/items -H "Content-Type: application/json" -d '{"items" : [{"name": "New Item", "position": 20}]}"'

Move this item to second to last

curl -X PUT localhost:8080/items -H "Content-Type: application/json" -d '{"items" : [{"id": 21, "position": 19}]}"'
1 # => 1 row affected

About

A small experiment using SQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published