Upgrade Guide
- Preparation: It is recommended that developers create a new project branch for this upgrade.
- Upgrade dependency package versions: npm i ee-bin@latest -D && npm i ee-core@latest
- Adjust configuration files:
- Refer to demo configuration
- Adjust package.json configuration, refer to package.json
- Remove string identifiers like
'[class ExampleController]'from js/ts files. These are no longer needed in v5. - SqliteStorage lazy load migration: constructor no longer opens the database connection. The native
better-sqlite3binding is now lazily loaded viainit(), avoiding unconditional module loading for projects that don't use SQLite.
Affected code:
| Before (v4) | After (v5 latest) |
|---|---|
new SqliteStorage(name, options) — constructor opens DB | new SqliteStorage(name) — constructor only computes paths |
this.db = this.storage.db available immediately | await this.storage.init(options) — must call before using this.db |
basedbService._init() — synchronous | basedbService._init() — now async, returns Promise<void> |
preload() — synchronous | preload() — now async, returns Promise<void> |
import Database from 'better-sqlite3' — loaded at import time | import type Database from 'better-sqlite3' — type-only; real import deferred to init() |
Migration steps:
- Change
SqliteStorageconstructor calls: remove the secondoptionsargument - Call
await storage.init(options)after construction, before accessingstorage.db - Update any code that was synchronous around DB initialization to use
async/await - If using
basedbService, the_init()andchangeDataDir()methods are now async — addawait - If using the
preload()function, it is now async — addawait
Example:
javascript
// Before
const storage = new SqliteStorage('myapp.db', { timeout: 6000 });
const db = storage.db;
// After
const storage = new SqliteStorage('myapp.db');
await storage.init({ timeout: 6000 });
const db = storage.db;
// Or chaining
const { db } = await new SqliteStorage('myapp.db').init({ timeout: 6000 });