Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wewatchwall/stark-db
SQLite-backed, change-tracking database available over HTTP.
https://github.com/wewatchwall/stark-db
sql sqlite
Last synced: 4 days ago
JSON representation
SQLite-backed, change-tracking database available over HTTP.
- Host: GitHub
- URL: https://github.com/wewatchwall/stark-db
- Owner: WeWatchWall
- License: mit
- Created: 2023-10-09T08:01:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-22T09:05:38.000Z (4 months ago)
- Last Synced: 2024-10-23T10:43:36.424Z (4 months ago)
- Topics: sql, sqlite
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/stark-db
- Size: 384 KB
- Stars: 60
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stark-db
[![Build and test status](https://github.com/WeWatchWall/stark-db/workflows/Node.js%20CI/badge.svg)](https://github.com/WeWatchWall/stark-db/actions?query=workflow%3A%22Node.js+CI%22)
[![NPM version](https://img.shields.io/npm/v/stark-db.svg)](https://www.npmjs.com/package/stark-db)SQLite-backed, change-tracking database available over HTTP.
## Installation
```bash
npm i -g stark-db
```## Basics
Run with:
```bash
stark-db
```By default, the DB engine is configured to run over SSL. While some self-signed
ssl certificates are automatically generated, they are not ever valid so
the user must supply their own. Then, the user needs to set the `-c` flag
in order to enable the cookie security. Only then is this system ready for
use in production.There is a Swagger endpoint `https://127.0.0.1:5984/api-docs` where the user can
try out the routes available.You may want to use `BEGIN IMMEDIATE TRANSACTION;` if you write to the database
concurrently as SQLite will throw busy errors otherwise.This database tracks changes to all entities in the auto-created column(on all
tables) `stark_version`. There is also an extra table generated with any
user-created table called `_stark_del_${name}`. Deletions are tracked
in this auxiliary set of tables. With the help of this change tracking,
synchronization mechanisms can be built later. The user has the option
of using soft deletion -- marking data as deleted -- or relying on an
`id` column to track such deletions. ROWID would not work in a synchronization
scenario. Any modifications made by stark-db to the sqlite database
can be seen by running `select * from sqlite_master;` and the user can edit the
triggers/tables.
Also, the `-f` flag prevents all modifications related to change tracking.It is recommended to invoke the API one query at a time although it is possible
to execute multiple statements in a single invocation. Interactive queries are
supported due to the stateful nature of the API. A DB connection is marked
inactive and is refreshed after 1 hour. A session cookie to the server is marked
inactive after 1 day.## CLI
```bash
HTTP address to listen on (default: "127.0.0.1")
-a, --address
-i, --doc Address to query by the documentation (default: "https://127.0.0.1")
-p, --port HTTP port to listen on (default: "5983")
-s, --ssl HTTPS port to listen on (default: "5984")
-c, --cookie Secure cookie, served over valid HTTPS only (default: false)
-d, --data Path to the data directory (default: "./data")
-k, --certs Path to the certs directory (default: "./certs")
-f, --simple Do not run change-tracking queries (default: false)
-h, --help display help for command
```
## Wiki
See the Wiki for [HTTP API Documentation](https://github.com/WeWatchWall/stark-db/wiki/HTTP-API-Documentation).