Skip to content

Commit 7762bb7

Browse files
committed
check for fc
1 parent 76e360e commit 7762bb7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/transactions.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,21 @@ def _create_item_index(self):
5454
def create_item(self, model: stac_types.Item, **kwargs):
5555
"""Create item."""
5656
base_url = str(kwargs["request"].base_url)
57-
5857
self._create_item_index()
5958

59+
# If a feature collection is posted
60+
if model["type"] == "FeatureCollection":
61+
bulk_client = BulkTransactionsClient()
62+
processed_items = [
63+
bulk_client._preprocess_item(item, base_url)
64+
for item in model["features"]
65+
]
66+
return_msg = f"Successfully added {len(processed_items)} items."
67+
bulk_client.bulk_sync(processed_items)
68+
69+
return return_msg
70+
71+
# If a single item is posted
6072
if not self.client.exists(index="stac_collections", id=model["collection"]):
6173
raise ForeignKeyError(f"Collection {model['collection']} does not exist")
6274

0 commit comments

Comments
 (0)