Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

534 B
Raw Blame
import type db from "../../database";
import { taskRelationTable } from "../../database/schema";
import { chunk } from "./chunk";
import type { PlannedImportRelation } from "./plan-import-relations";

type Transaction = Parameters<Parameters<typeof db.transaction>[0]>[0];

export async function writeImportRelations(
  tx: Transaction,
  relations: readonly PlannedImportRelation[],
): Promise<number> {
  for (const batch of chunk(relations)) {
    await tx.insert(taskRelationTable).values(batch);
  }
  return relations.length;
}