DEV Community

Cover image for Soul, SQLite REST server is realtime now.
Vahid Al
Vahid Al

Posted on

Soul, SQLite REST server is realtime now.

Hi Folks, It's been an amazing journey since I first published Soul on HN and now I added a really major feature that Soul lacked, Realtime changes via Websockets.
For those who are not familiar with Soul, it basically takes a SQLite database file and run a CRUD API on it, so you can have a minimal backend with no code.

Now thanks to this new feature, users can subscribe to changes in a table and whenever a Create, Update or Delete operation happens, Soul will send the realtime data to subscribers.

If you need some examples on how to work with websockets in Soul, you can find a bunch of examples here: https://github.com/thevahidal/soul/blob/main/docs/ws-examples.md

Please let me know what you think of this new feature and also submit any issues you faced so we can fix them as soon as possible.

Also if you have ideas to make Soul a better tool, please send me your ideas, it'll help me a lot.

Here's a small example of how realtime works in Soul:

 # Install Soul
npm install -g soul-cli 

# Install websocket client to test Soul realtime
npm i -g wscat

 # Download sample sqlite database
wget https://raw.githubusercontent.com/lerocha/chinook-database/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite

# Run Soul
soul -d ./Chinook_Sqlite.sqlite -p 8000

# Subscribe to Employee table realtime changes
wscat -c ws://localhost:8000/ws/tables/Employee
Enter fullscreen mode Exit fullscreen mode

Then to test it, in a new terminal, insert a new row in the table Employee:
to test it, in a new terminal, insert a new row in the table Employee:

curl --request POST \
  --url http://localhost:8000/api/tables/Employee/rows \
  --header 'Content-Type: application/json' \
  --data '{
    "fields": {
        "FirstName": "Damien",
        "LastName": "Rice"
    }
}'
Enter fullscreen mode Exit fullscreen mode

Checkout wscat terminal, it should respond with the following message:

{
  "type": "INSERT",
  "data": {
    "pk": 10,
    "FirstName": "Damien",
    "LastName": "Rice"
  }
}
Enter fullscreen mode Exit fullscreen mode

You can test the same thing with Update and Delete operations too.

Once again thanks for the support and I'll see you in the next one!

Repo: https://github.com/thevahidal/soul
HN: https://news.ycombinator.com/item?id=33484693

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry đź‘€

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay