update meilis
This commit is contained in:
@@ -19,7 +19,7 @@ def lambda_handler(event: DynamoDBStreamEvent, context: LambdaContext):
|
||||
with Op(meili_client) as op:
|
||||
for record in event.records:
|
||||
pk = record.dynamodb.keys['id'] # type: ignore
|
||||
new_image = record.dynamodb.new_image # type: ignore
|
||||
new_image = sanitize(record.dynamodb.new_image) # type: ignore
|
||||
index = table_from_arn(record.event_source_arn) # type: ignore
|
||||
|
||||
op.append(
|
||||
@@ -32,3 +32,13 @@ def lambda_handler(event: DynamoDBStreamEvent, context: LambdaContext):
|
||||
def table_from_arn(arn: str) -> str:
|
||||
arn_ = arnparse(arn)
|
||||
return arn_.resource.split('/')[0]
|
||||
|
||||
|
||||
# Post-migration: remove the following line
|
||||
def sanitize(obj):
|
||||
if isinstance(obj, dict):
|
||||
return {k.replace(':', '__'): sanitize(v) for k, v in obj.items()}
|
||||
elif isinstance(obj, list):
|
||||
return [sanitize(item) for item in obj]
|
||||
else:
|
||||
return obj
|
||||
|
||||
Reference in New Issue
Block a user