mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:27:08 -04:00 
			
		
		
		
	remove nesting
This commit is contained in:
		
							parent
							
								
									1691706666
								
							
						
					
					
						commit
						c15507baad
					
				| @ -32,18 +32,20 @@ export async function getVectorExtension(runner: Kysely<DB> | QueryRunner): Prom | ||||
|   } | ||||
| 
 | ||||
|   cachedVectorExtension = new ConfigRepository().getEnv().database.vectorExtension; | ||||
|   if (!cachedVectorExtension) { | ||||
|     let availableExtensions: { name: VectorExtension }[]; | ||||
|     const query = `SELECT name FROM pg_available_extensions WHERE name IN (${VECTOR_EXTENSIONS.map((ext) => `'${ext}'`).join(', ')})`; | ||||
|     if (runner instanceof Kysely) { | ||||
|       const { rows } = await sql.raw<{ name: VectorExtension }>(query).execute(runner); | ||||
|       availableExtensions = rows; | ||||
|     } else { | ||||
|       availableExtensions = (await runner.query(query)) as { name: VectorExtension }[]; | ||||
|     } | ||||
|     const extensionNames = new Set(availableExtensions.map((row) => row.name)); | ||||
|     cachedVectorExtension = VECTOR_EXTENSIONS.find((ext) => extensionNames.has(ext)); | ||||
|   if (cachedVectorExtension) { | ||||
|     return cachedVectorExtension; | ||||
|   } | ||||
| 
 | ||||
|   let availableExtensions: { name: VectorExtension }[]; | ||||
|   const query = `SELECT name FROM pg_available_extensions WHERE name IN (${VECTOR_EXTENSIONS.map((ext) => `'${ext}'`).join(', ')})`; | ||||
|   if (runner instanceof Kysely) { | ||||
|     const { rows } = await sql.raw<{ name: VectorExtension }>(query).execute(runner); | ||||
|     availableExtensions = rows; | ||||
|   } else { | ||||
|     availableExtensions = (await runner.query(query)) as { name: VectorExtension }[]; | ||||
|   } | ||||
|   const extensionNames = new Set(availableExtensions.map((row) => row.name)); | ||||
|   cachedVectorExtension = VECTOR_EXTENSIONS.find((ext) => extensionNames.has(ext)); | ||||
|   if (!cachedVectorExtension) { | ||||
|     throw new Error(`No vector extension found. Available extensions: ${VECTOR_EXTENSIONS.join(', ')}`); | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user