- Add support for initializing SQLocal with an in-memory database. Specifying
:memory:
as the databasePath
for an SQLocal
instance puts it in memory mode with support for all SQLocal methods including importing, exporting, and clearing the database.
- Add
onInit
hook that can be used to set SQL statements that should be run whenever the SQLocal
instance makes a new database connection. These statements are always executed before any other statements can run on the connection. This makes it the best place to set PRAGMA
settings or create temporary tables, views, triggers, or other connection-specific commands.
new SQLocal({
databasePath: 'database.sqlite3',
onInit: (sql) => [
sql`PRAGMA foreign_keys = ON`,
sql`CREATE TEMP VIEW hrEmployees AS
SELECT name, salary
FROM employees
WHERE department = 'HR'`,
],
})
- The
onConnect
hook is now passed a reason
argument to specify why the hook was called: for initialization, because of database overwrite, or because of database deletion.