Reference · Database

db.system

signature
db.system(str) -> null | error(str)

What it does

Names the system database: where Quillo keeps its own tables, the scheduled jobs (_quillo_jobs), the decisions of db.atomic (_quillo_atomic) and the calls a service answered. Calls made later stay with the work, in the program's database or the tenant's, and only go here when there is neither. Without it they go to the program's database, or, when that is one per tenant, to $QUILLO_SYSTEM_DB or a SQLite file quillo-system.db next to the program. Several servers of one program share one system database, so give them a server URL. It gives null when the database is open and an error value when it is not.

Examples

print(db.system("system.db"))print(db.query("select 1 as still_the_program_database"))
output
null[{ still_the_program_database: 1 }]
in a program
db.open("data/{tenant}.db")          // a database per tenant: jobs cannot live theredb.system(env("SYSTEM_DB_URL"))      // one for every server of the program

Edge cases

print(db.system("system.db"), db.system("system.db"))print(db.system("nope/dir/system.db") | is_err)
output
null nulltrue

Errors

A path that cannot be opened is an error value; a target that is not a string is a runtime error.

this one fails
print(db.system(1))
output
line 1: `db.system` expects a path or a database URL

Chaining

Called once, at the top of the program, after db.open:

print("system.db" | db.system)
output
null

See also

db.open, db.atomic, db.tenants, schedule

Thread
8Useful? Like it, or add to its thread below.

Thread 0 posts

On db.system(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo