Expand description
Re-exports§
pub use prefixed::LOCK_WAIT;pub use prefixed::PREFIX;pub use prefixed::Prefixed;pub use prefixed::TABLES;pub use prefixed::TablesBusyError;pub use prefixed::check_prefix;pub use prefixed::lock_wait;
Macros§
- params
- Builds a parameter list:
params![site, from, to].
Structs§
- DbError
- A database that refused a statement, or could not be reached.
- Event
Row - One recorded row: a pageview, event, engagement ping, link click, or AI agent fetch.
- Funnel
Row - Steps a visit is expected to take in order.
- Funnel
Step - One step of a funnel: reaching a page (with * as a wildcard), or sending an event.
- GoalRow
- Something worth counting.
- Goal
Totals - A goal’s totals.
- LinkRow
- A short link.
- Pageview
Info - The pageview an engagement ping or event belongs to.
- Prefixed
- A Db whose tables and indexes start with a prefix in place of
rl_, such aswp_rl_inside WordPress, so two apps sharing one database each keep a set of their own. Runlight’s SQL names every table and indexrl_and something, and those names alone are rewritten on the way through, in each statement and in the names a schema check compares as text. Values bound as parameters are left as they are. A store given a prefix puts one in front of its Db, so the accounts and importers that reach the Db through the store follow it too. - Report
Row - Someone who gets a site’s report by email.
tokenis the unsubscribe key. - Row
- One row, its columns by name.
- Session
Row - A visit, as recorded from its first request.
- Share
Row - A public, read-only view of one site’s stats, opened by its unguessable id.
- SiteRow
- A site.
- SqlStore
- Runlight’s tables in a database: everything recorded, and every report read from it.
- Stats
- A range’s totals.
- Tables
Busy Error - Another process held the lock for creating tables past the wait, such as one building an index on a
big table after an upgrade. The request that waited fails with this, rather than waiting for good. It
reaches the store as a
DbErrorwith its words, whichTablesBusyError::ofknows again. - Token
Row - An API token. Only its hash is stored; the token itself is shown once.
Enums§
- Cell
- A column’s value, as the driver gave it.
- Dialect
- The SQL a database speaks.
- Hold
- What a held connection is for.
- Param
- A statement’s parameter, in the types a JavaScript driver binds.
Constants§
- BOUNCE_
MS - A session’s bounce: one page, nothing clicked that was tracked, under ten seconds engaged.
- EVENT_
TAIL_ MS - How long after a visit starts its events are looked for: far past any real visit.
- JOURNEY_
VISITS - The most visits journeys reads, newest first.
- LOCK_
WAIT - The longest a process waits for another one creating or upgrading the tables before it gives up.
- MYSQL_
COLLATION - MySQL’s text collation: UTF-8 compared and sorted by code point, case and trailing spaces included, as SQLite and Postgres’s “C” collation do. MariaDB has it too, from 11.4.
- PREFIX
- What every table and index name starts with, unless a store is given another prefix in its place.
- TABLES
- Runlight’s tables, after the prefix: the store’s, and the sign-in accounts’ two. An app dropping Runlight’s tables drops these by name, never every table that starts with the prefix.
Traits§
- Db
- The little a store needs from a database driver. SQL uses
?placeholders and “double quotes” around a name that is a keyword somewhere; a driver numbers the placeholders, or fills them in and quotes names its own way, as the TypeScript drivers do.
Functions§
- check_
prefix - Checks a table prefix, with the error the SDK throws for one that cannot be.
- fill_
placeholders - SQL written with
?placeholders and “double quoted” names, with each placeholder outside quotes filled in byfill, as node-postgres and mysql2 send values in the statement’s text. For MySQL, a “quoted” name goes in backticks and a backslash inside ‘text’ is doubled, since MySQL reads it as an escape where standard SQL takes it literally. - js_
order - Compares as JavaScript’s
<does: by UTF-16 code units. - lock_
wait - How long a Db waits for the lock for creating tables:
LOCK_WAIT, unless a test has set another. - mysql_
literal - A value as a MySQL literal, as mysql2’s escape() writes the values Runlight binds, except that a quote is doubled rather than escaped with a backslash, so a value stays inside its quotes even on a connection whose sql_mode has NO_BACKSLASH_ESCAPES.
- postgres_
literal - A value as a Postgres literal of unknown type, which the server reads as it reads a parameter
node-postgres sends untyped:
E'...'text (backslashes and quotes escaped, whatever standard_conforming_strings says), numbers too, and NULL.
Type Aliases§
- Site
Overrides - What the dashboard may change about a site, kept as the JSON object it
was saved as (
{ name?, timezone? }).