Skip to content

Commit c0e3361

Browse files
committed
create stac to db method for items
1 parent 4eaedc5 commit c0e3361

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/serializers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def db_to_stac(cls, item: dict, base_url: str) -> TypedDict:
2121

2222
class ItemSerializer(Serializer):
2323
"""Serialization methods for STAC items."""
24+
@classmethod
25+
def stac_to_db(cls, stac_data: TypedDict) -> stac_types.Item:
26+
return stac_data
2427

2528
@classmethod
2629
def db_to_stac(cls, item: dict, base_url: str) -> stac_types.Item:

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/transactions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def create_item(self, model: stac_types.Item, **kwargs):
8181

8282
self._create_item_index()
8383

84+
data = ItemSerializer.stac_to_db(model)
85+
8486
self.client.index(
85-
index="stac_items", doc_type="_doc", id=model["id"], document=model
87+
index="stac_items", doc_type="_doc", id=model["id"], document=data
8688
)
8789
return ItemSerializer.db_to_stac(model, base_url)
8890

0 commit comments

Comments
 (0)