Fix delete item API MongoDB query - Fix sections.$.items to sections.$[].items for proper array update
Browse files
main.py
CHANGED
|
@@ -1031,8 +1031,8 @@ async def delete_checklist_item(user_id: str, item_id: str):
|
|
| 1031 |
|
| 1032 |
# Remove the item from the checklist
|
| 1033 |
result = await db.checklists.update_one(
|
| 1034 |
-
{"userId": user_id
|
| 1035 |
-
{"$pull": {"sections
|
| 1036 |
)
|
| 1037 |
|
| 1038 |
if result.modified_count > 0:
|
|
|
|
| 1031 |
|
| 1032 |
# Remove the item from the checklist
|
| 1033 |
result = await db.checklists.update_one(
|
| 1034 |
+
{"userId": user_id},
|
| 1035 |
+
{"$pull": {"sections.$[].items": {"id": item_id}}}
|
| 1036 |
)
|
| 1037 |
|
| 1038 |
if result.modified_count > 0:
|