Skip to content

Commit b699213

Browse files
committed
Removing collection parameter
1 parent 88efcd4 commit b699213

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

arangoasync/database.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,6 @@ async def insert_document(
835835

836836
async def update_document(
837837
self,
838-
collection: str,
839838
document: Json,
840839
ignore_revs: Optional[bool] = None,
841840
wait_for_sync: Optional[bool] = None,
@@ -851,7 +850,6 @@ async def update_document(
851850
"""Update a document.
852851
853852
Args:
854-
collection (str): Collection name.
855853
document (dict): Partial or full document with the updated values.
856854
It must contain the "_key" or "_id" field.
857855
ignore_revs (bool | None): If set to `True`, the `_rev` attribute in the
@@ -891,7 +889,9 @@ async def update_document(
891889
References:
892890
- `update-a-document <https://docs.arangodb.com/stable/develop/http-api/documents/#update-a-document>`__
893891
""" # noqa: E501
894-
col: StandardCollection[Json, Json, Jsons] = self.collection(collection)
892+
col: StandardCollection[Json, Json, Jsons] = self.collection(
893+
Collection.get_col_name(document)
894+
)
895895
return await col.update(
896896
document,
897897
ignore_revs=ignore_revs,
@@ -908,7 +908,6 @@ async def update_document(
908908

909909
async def replace_document(
910910
self,
911-
collection: str,
912911
document: Json,
913912
ignore_revs: Optional[bool] = None,
914913
wait_for_sync: Optional[bool] = None,
@@ -922,7 +921,6 @@ async def replace_document(
922921
"""Replace a document.
923922
924923
Args:
925-
collection (str): Collection name.
926924
document (dict): New document. It must contain the "_key" or "_id" field.
927925
Edge document must also have "_from" and "_to" fields.
928926
ignore_revs (bool | None): If set to `True`, the `_rev` attribute in the
@@ -956,7 +954,9 @@ async def replace_document(
956954
References:
957955
- `replace-a-document <https://docs.arangodb.com/stable/develop/http-api/documents/#replace-a-document>`__
958956
""" # noqa: E501
959-
col: StandardCollection[Json, Json, Jsons] = self.collection(collection)
957+
col: StandardCollection[Json, Json, Jsons] = self.collection(
958+
Collection.get_col_name(document)
959+
)
960960
return await col.replace(
961961
document,
962962
ignore_revs=ignore_revs,
@@ -971,7 +971,6 @@ async def replace_document(
971971

972972
async def delete_document(
973973
self,
974-
collection: str,
975974
document: str | Json,
976975
ignore_revs: Optional[bool] = None,
977976
ignore_missing: bool = False,
@@ -984,7 +983,6 @@ async def delete_document(
984983
"""Delete a document.
985984
986985
Args:
987-
collection (str): Collection name.
988986
document (str | dict): Document ID, key or body. The body must contain the
989987
"_key" or "_id" field.
990988
ignore_revs (bool | None): If set to `True`, the `_rev` attribute in the
@@ -1017,7 +1015,9 @@ async def delete_document(
10171015
References:
10181016
- `remove-a-document <https://docs.arangodb.com/stable/develop/http-api/documents/#remove-a-document>`__
10191017
""" # noqa: E501
1020-
col: StandardCollection[Json, Json, Jsons] = self.collection(collection)
1018+
col: StandardCollection[Json, Json, Jsons] = self.collection(
1019+
Collection.get_col_name(document)
1020+
)
10211021
return await col.delete(
10221022
document,
10231023
ignore_revs=ignore_revs,

tests/test_document.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -594,23 +594,23 @@ async def test_document_db_operations(db, bad_db, doc_col, docs):
594594

595595
# Update the document
596596
doc["val"] = 100
597-
updated_doc = await db.update_document(doc_col.name, doc, return_new=True)
597+
updated_doc = await db.update_document(doc, return_new=True)
598598
assert updated_doc["_id"] == doc["_id"]
599599
assert updated_doc["new"]["val"] == 100
600600
with pytest.raises(DocumentUpdateError):
601-
await bad_db.update_document(doc_col.name, doc)
601+
await bad_db.update_document(doc)
602602

603603
# Replace the document
604604
doc["val"] = 200
605-
replaced_doc = await db.replace_document(doc_col.name, doc, return_new=True)
605+
replaced_doc = await db.replace_document(doc, return_new=True)
606606
assert replaced_doc["_id"] == doc["_id"]
607607
assert replaced_doc["new"]["val"] == 200
608608
with pytest.raises(DocumentReplaceError):
609-
await bad_db.replace_document(doc_col.name, doc)
609+
await bad_db.replace_document(doc)
610610

611611
# Delete the document
612-
deleted_doc = await db.delete_document(doc_col.name, doc["_id"], return_old=True)
612+
deleted_doc = await db.delete_document(doc["_id"], return_old=True)
613613
assert deleted_doc["_id"] == doc["_id"]
614614
assert deleted_doc["old"]["val"] == 200
615615
with pytest.raises(DocumentDeleteError):
616-
await bad_db.delete_document(doc_col.name, doc)
616+
await bad_db.delete_document(doc)

0 commit comments

Comments
 (0)