Skip to content

Commit

Permalink
feat(endpoint-media): replace existing if uploading media with the sa…
Browse files Browse the repository at this point in the history
…me url
  • Loading branch information
paulrobertlloyd committed Oct 8, 2024
1 parent b3b0baa commit fc24e1c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/endpoint-media/lib/media-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export const mediaData = {

const mediaData = { path, properties };

// Add data to media collection (if present)
// Add data to media collection (or replace existing if present)
if (hasDatabase) {
await media.insertOne(mediaData);
const query = { "properties.url": properties.url };
await media.replaceOne(query, mediaData, { upsert: true });
}

return mediaData;
Expand Down

0 comments on commit fc24e1c

Please sign in to comment.