1.3.1 • Published 4 months ago

@cloud-cli/d0 v1.3.1

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

d0

SQLite server over HTTP

Usage

POST /query

Run a prepared SQLite statement. Accepts a JSON with these properties:

PropertyDescriptionRequired
sstring with the statementyes
ddata to bind on a statementno
mmethod to execute: all, run or get. Run is the defaultno
// select all items using fetch
fetch('https://db.example.com/query', {
  method: 'POST',
  body: JSON.stringify({
    s: 'SELECT * FROM user WHERE id = ?',
    d: [123],
    m: 'all',
  });
});

// select using the server-provided library
import db from 'https://db.example.com/index.mjs';

const user = await db.query('SELECT * FROM user WHERE id = ?', [123]);

Server address

If BASE_DOMAIN is set, the server will be available at https://db-name.BASE_DOMAIN/ with a multi-database support, where db-name is the name of the database file without the .sqlite extension. The database is selected by the db-name part of the URL, so you can have multiple databases on the same server.

Otherwise, it will be available at http://localhost:PORT/ and serve a single database.

Environment variables

VariableDescription
PORTHTTP port
DATA_PATHPath to a folder where the database files are stored
BASE_DOMAINRoot domain to use in a multi-db server, e.g. .example.com
1.2.0

7 months ago

1.3.1

4 months ago

1.3.0

4 months ago

1.2.1

7 months ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago