Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
757 |
-
|
758 |
-
|
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'
|