21 lines
607 B
TypeScript
21 lines
607 B
TypeScript
import { chunkTable, sourceTable } from '../schema';
|
|
|
|
type Chunk = typeof chunkTable.$inferInsert;
|
|
type Source = typeof sourceTable.$inferSelect;
|
|
|
|
function findByName({ name: sourceName }: Source, name: String) { return sourceName === name }
|
|
function findIdByName(sources: Source[], name: String): number | undefined {
|
|
return sources.find(source => findByName(source, name))?.id
|
|
}
|
|
|
|
function data(sources: Source[]): Array<Chunk> {
|
|
return [
|
|
{
|
|
name: 'Distinctive Flaws',
|
|
pages: ['56'],
|
|
sourceId: findIdByName(sources, 'Pirate Borg')
|
|
}
|
|
] as Array<Chunk>
|
|
}
|
|
|
|
export default data;
|