( keys: string[], context: StorageContext, executor: Pick<typeof db, 'select'> = db )
| 186 | * Batches what would otherwise be N `getFileMetadataByKey` calls. |
| 187 | */ |
| 188 | export async function getFileMetadataByKeys( |
| 189 | keys: string[], |
| 190 | context: StorageContext, |
| 191 | executor: Pick<typeof db, 'select'> = db |
| 192 | ): Promise<FileMetadataRecord[]> { |
| 193 | if (keys.length === 0) { |
| 194 | return [] |
| 195 | } |
| 196 | return executor |
| 197 | .select() |
| 198 | .from(workspaceFiles) |
| 199 | .where( |
| 200 | and( |
| 201 | inArray(workspaceFiles.key, keys), |
| 202 | eq(workspaceFiles.context, context), |
| 203 | isNull(workspaceFiles.deletedAt) |
| 204 | ) |
| 205 | ) |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Get file metadata by ID |
no test coverage detected