File size: 1,042 Bytes
eb846d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import { initializeDatabase, closeDatabase, isDatabaseConnected } from './connection.js';
import * as repositories from './repositories/index.js';
/**
* Initialize the database module
*/
export async function initializeDbModule(): Promise<boolean> {
try {
// Connect to the database
await initializeDatabase();
return true;
} catch (error) {
console.error('Failed to initialize database module:', error);
return false;
}
}
/**
* Get the repository factory for a database entity type
* @param entityType The type of entity to get a repository for
*/
export function getRepositoryFactory(entityType: 'vectorEmbeddings') {
// Return the appropriate repository based on entity type
switch (entityType) {
case 'vectorEmbeddings':
return () => new repositories.VectorEmbeddingRepository();
default:
throw new Error(`Unknown entity type: ${entityType}`);
}
}
// Re-export everything from the database module
export { initializeDatabase, closeDatabase, isDatabaseConnected, repositories };
|