From 4eae509718e58c0563dfcbc80b6dae61548192a5 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 22 Aug 2024 08:58:37 +0100 Subject: [PATCH] change add() method args --- jamesql/index.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jamesql/index.py b/jamesql/index.py index d9ff24e..8efb951 100644 --- a/jamesql/index.py +++ b/jamesql/index.py @@ -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: @@ -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