Skip to content

Commit

Permalink
fix(storeMetadata): handling of properties field
Browse files Browse the repository at this point in the history
When properties are attached to the metadata, first parse the object to
make it suitable for storage
  • Loading branch information
bitbeckers committed Jan 3, 2025
1 parent 04d45e2 commit 0f3b09e
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/storage/storeMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const storeMetadata: StorageMethod<MetadataResult> = async ({
requests.push(
dbClient
.insertInto("metadata")
.values(metadata.metadata)
.values({
...metadata.metadata,
properties: metadata.metadata.properties ? JSON.stringify(metadata.metadata.properties) : null
})
.onConflict((oc) => oc.columns(["uri"]).doNothing())
.compile(),
);
Expand All @@ -62,10 +65,13 @@ export const storeMetadata: StorageMethod<MetadataResult> = async ({
// Store allow_list_data
requests.push(
dbClient
.insertInto("allow_list_data")
.values(metadata.allow_list)
.onConflict((oc) => oc.columns(["uri"]).doNothing())
.compile(),
.insertInto("allow_list_data")
.values({
...metadata.allow_list,
data: JSON.stringify(metadata.allow_list.data)
})
.onConflict((oc) => oc.columns(["uri"]).doNothing())
.compile(),
);

// Store hypercert_allow_list_records
Expand Down Expand Up @@ -102,12 +108,14 @@ export const storeMetadata: StorageMethod<MetadataResult> = async ({
}

// Store hypercert_allow_lists as parsed
requests.push(
dbClient
.insertInto("hypercert_allow_lists")
.values(metadata.hypercert_allow_list)
.compile(),
);
if (metadata.hypercert_allow_list) {
requests.push(
dbClient
.insertInto("hypercert_allow_lists")
.values(metadata.hypercert_allow_list)
.compile(),
);
}

requests.push(
dbClient
Expand Down

0 comments on commit 0f3b09e

Please sign in to comment.