Skip to content

Commit

Permalink
Fix item type lookup in inspireDataset migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerdbeentjes committed Oct 18, 2024
1 parent 1dbebe1 commit 0720a4a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion migrations/1729260241_inspireDatasetFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ export default async function (client: Client) {
console.log("Creating new fields/fieldsets");

const itemTypes = await client.itemTypes.list();

const inspireDatasetItemType = itemTypes.find(
(itemType: any) => itemType.apiKey === "inspire_dataset"
(itemType: any) => itemType.api_key === "inspire_dataset"
) || { id: "" };

if (inspireDatasetItemType === undefined) {
throw new Error("Item type 'inspire_dataset' not found");
}

const fieldsets = await client.fieldsets.list(inspireDatasetItemType.id);
const findFieldset = (title: string) =>
fieldsets.find((fieldset: any) => fieldset.title === title);
Expand Down

0 comments on commit 0720a4a

Please sign in to comment.