Ignore foreign key violation on bulk insert

Is there a way to just skip the value, or even better make it null if one of the values from a bulk insert vauses a foreign key violation error
for example i have this code, and the second element as a recipeId that doesn't exist so i would get a foreign key violation error
Is there a way to just skip the second element or make recipeId null for the second element (recipeId is a nullable field)
  await db.insert(menuItemTable).values([
    {
      menuId: 1,
      name: "test item 1",
      description: "item.description",
      price: 12, 
      recipeId: 8,
    },
    {
      menuId: 1,
      name: "test item 2",
      description: "item.description",
      price: 12, 
      recipeId: 12, // there is no recipe with id 12
    },
    {
      menuId: 1,
      name: "test item 3",
      description: "item.description",
      price: 12,
      recipeId: 8,
    },
  ]);
Was this page helpful?