Reference · Database
db.system
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"))null[{ still_the_program_database: 1 }]db.open("data/{tenant}.db") // a database per tenant: jobs cannot live theredb.system(env("SYSTEM_DB_URL")) // one for every server of the programEdge cases
- It keeps Quillo's tables apart from the program's even when there is one database.
- The program's
dbcalls do not go to it: it is not anotherdb.open. - A file that cannot be opened is an error value; the program goes on.
- Calling it again with the same target is harmless.
print(db.system("system.db"), db.system("system.db"))print(db.system("nope/dir/system.db") | is_err)null nulltrueErrors
A path that cannot be opened is an error value; a target that is not a string is a runtime error.
print(db.system(1))line 1: `db.system` expects a path or a database URLChaining
Called once, at the top of the program, after db.open:
print("system.db" | db.system)nullSee also
db.open, db.atomic, db.tenants, schedule
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