awacke1 commited on
Commit
7987f44
·
verified ·
1 Parent(s): f70b960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -20
app.py CHANGED
@@ -752,31 +752,20 @@ def main():
752
  if st.button("🗑️ Delete", key=f'delete_button_{st.session_state.current_index}'):
753
  try:
754
  current_doc = json.loads(doc_str)
755
-
756
- # Get client directly from container's client property
757
- partitionKey = current_doc['id']
758
- client = st.session_state.client
759
-
760
- # Set up delete options
761
- options = {
762
- 'enableCrossPartitionQuery': True,
763
- 'partitionKey': partitionKey
764
- }
765
-
766
- # Construct document link
767
- doc_link = f"dbs/{DATABASE_NAME}/colls/{CONTAINER_NAME}/docs/{partitionKey}"
768
-
769
- # Delete using client directly
770
- response = client.DeleteItem(doc_link, options)
771
-
772
- if response:
773
- st.success(f"Document {partitionKey} deleted successfully.")
774
  if st.session_state.current_index > 0:
775
  st.session_state.current_index -= 1
776
  st.rerun()
777
  except Exception as e:
778
- st.error(f"Error deleting document: {str(e)}")
 
 
779
 
 
 
780
 
781
  elif selected_view == 'Show as Edit, Save, Run AI':
782
  Label = '# ✏️ Edit and save view - Edit with wisdom, save with precision'
 
752
  if st.button("🗑️ Delete", key=f'delete_button_{st.session_state.current_index}'):
753
  try:
754
  current_doc = json.loads(doc_str)
755
+ # Direct deletion using container method with id and partition key
756
+ delete = container.delete_item(current_doc["id"], current_doc["id"])
757
+ if delete:
758
+ st.success(f"Document {current_doc['id']} deleted successfully.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759
  if st.session_state.current_index > 0:
760
  st.session_state.current_index -= 1
761
  st.rerun()
762
  except Exception as e:
763
+ st.error(f"Error deleting document: {str(e)}")
764
+
765
+
766
 
767
+
768
+
769
 
770
  elif selected_view == 'Show as Edit, Save, Run AI':
771
  Label = '# ✏️ Edit and save view - Edit with wisdom, save with precision'