Won't Update Database After Deleting Gallery Item

So I have a client who wants to delete and manage photos in a gallery field in a collection from the site itself. I can upload to the collection but i’m trying to delete a specific item from the gallery field with code. It is deleting and it says so in the verbose debug preview, but the cms is not changing at all. Any help would be appreciated. here is screenshots and my code.

import { local } from 'wix-storage-frontend';
import wixData from 'wix-data';

$w.onReady(function () {
  $w("#gallery1").onItemClicked((event) => {

    let index = event.itemIndex;
    local.setItem("index", index);
    $w("#button7").label = index.toLocaleString('en');
    console.log("Gallery Item Title=" + event.item.title)
    console.log("gallery#:", index)

    let image = event.item.title
    let imagecover = event.item.src
    let eventname = $w('#button7').label


export function button7_click(event) {
  let currentItem = ($w("#dataset1").getCurrentItem())

  let index = local.getItem("index"); // "value"
  currentItem.photos.splice(index, 1)
  console.log("item removed")
  $w('#button7').label = "item removed"
  console.log("completed delete process")

  wixData.update("photos", currentItem)


When I select the image in the database

When I click the button to remove it.

I’m not too familiar with this functionality but there’s two possibilities that I can see:

$w('#dataset1').save is not being called so it’s not saving the dataset. Would need to be $w('#dataset1').save() to call the function. Depending on the design of your site this might be the issue.

Alternatively to delete file on the backend you’ll need to:

  1. Define a web module
  2. Make sure it and your database permissions are set securely so users can’t delete items they’re not supposed to
  3. Use one of these functions to do the deletion: