export default async function deletePhoto(db, id) {
  var _a, _b, _c, _d, _e, _f, _g, _h;
  const data = await db.find("photos", id);
  if ((_a = data === null || data === void 0 ? void 0 : data.job) === null || _a === void 0 ? void 0 : _a.id)
    await db.update("jobs", (_b = data === null || data === void 0 ? void 0 : data.job) === null || _b === void 0 ? void 0 : _b.id, { updatedAt: new Date() });
  if ((_c = data === null || data === void 0 ? void 0 : data.site) === null || _c === void 0 ? void 0 : _c.id)
    await db.update("sites", (_d = data === null || data === void 0 ? void 0 : data.site) === null || _d === void 0 ? void 0 : _d.id, { updatedAt: new Date() });
  if ((_e = data === null || data === void 0 ? void 0 : data.service) === null || _e === void 0 ? void 0 : _e.id)
    await db.update("services", (_f = data === null || data === void 0 ? void 0 : data.service) === null || _f === void 0 ? void 0 : _f.id, { updatedAt: new Date() });
  if ((_g = data === null || data === void 0 ? void 0 : data.inventory) === null || _g === void 0 ? void 0 : _g.id)
    await db.update("inventories", (_h = data === null || data === void 0 ? void 0 : data.inventory) === null || _h === void 0 ? void 0 : _h.id, {
      updatedAt: new Date(),
    });
  return db.delete("photos", id);
}
