Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
fix: only execute bulk write if there is writes to do
Browse files Browse the repository at this point in the history
  • Loading branch information
tnix100 committed Nov 12, 2024
1 parent 9b1205a commit 0d8589d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion database.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ def get_total_pages(collection: str, query: dict, page_size: int = 25) -> int:
{"_id": post["_id"]},
{"$set": {"attachments": [attachment["id"] for attachment in post["attachments"]]}}
))
db.posts.bulk_write(updates)
if len(updates):
db.posts.bulk_write(updates)

db.config.update_one({"_id": "migration"}, {"$set": {"database": CURRENT_DB_VERSION}})
log(f"[Migrator] Finished Migrating DB to version {CURRENT_DB_VERSION}")
Expand Down

0 comments on commit 0d8589d

Please sign in to comment.