Initial commit - Event Planner application
This commit is contained in:
27
node_modules/@mikro-orm/sql/dialects/sqlite/BaseSqliteConnection.js
generated
vendored
Normal file
27
node_modules/@mikro-orm/sql/dialects/sqlite/BaseSqliteConnection.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { CompiledQuery } from 'kysely';
|
||||
import { AbstractSqlConnection } from '../../AbstractSqlConnection.js';
|
||||
export class BaseSqliteConnection extends AbstractSqlConnection {
|
||||
createKyselyDialect(options) {
|
||||
throw new Error(
|
||||
'No SQLite dialect configured. Pass a Kysely dialect via the `driverOptions` config option, ' +
|
||||
'e.g. `new NodeSqliteDialect(...)` for node:sqlite or a custom dialect for other libraries.',
|
||||
);
|
||||
}
|
||||
async connect(options) {
|
||||
await super.connect(options);
|
||||
await this.getClient().executeQuery(CompiledQuery.raw('pragma foreign_keys = on'));
|
||||
await this.attachDatabases();
|
||||
}
|
||||
async attachDatabases() {
|
||||
const attachDatabases = this.config.get('attachDatabases');
|
||||
if (!attachDatabases?.length) {
|
||||
return;
|
||||
}
|
||||
const { fs } = await import('@mikro-orm/core/fs-utils');
|
||||
const baseDir = this.config.get('baseDir');
|
||||
for (const db of attachDatabases) {
|
||||
const path = fs.absolutePath(db.path, baseDir);
|
||||
await this.execute(`attach database '${path}' as ${this.platform.quoteIdentifier(db.name)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user