Skip to content

Commit

Permalink
change add() method args
Browse files Browse the repository at this point in the history
  • Loading branch information
capjamesg committed Aug 22, 2024
1 parent 929505b commit 4eae509
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions jamesql/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def load(self, index_name: str) -> None:
]
self.gsis = structure["gsis"]

def add(self, document: list, partition_key=None) -> Dict[str, dict]:
def add(self, document: list, doc_id=None) -> Dict[str, dict]:
"""
This function accepts a list of documents and turns them into a dictionary with the structure:
Expand All @@ -176,12 +176,12 @@ def add(self, document: list, partition_key=None) -> Dict[str, dict]:
Every document is assigned a UUID.
"""

document["uuid"] = uuid.uuid4().hex

if partition_key is None:
partition_key = document["uuid"]
if doc_id:
document["uuid"] = doc_id
else:
doc_uuid = uuid.uuid4().hex

self.global_index[partition_key] = document
self.global_index[doc_uuid] = document

self.uuids_to_position_in_global_index[document["uuid"]] = (
len(self.global_index) - 1
Expand Down

0 comments on commit 4eae509

Please sign in to comment.