Skip to content

Commit fc24e1c

Browse files
feat(endpoint-media): replace existing if uploading media with the same url
1 parent b3b0baa commit fc24e1c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/endpoint-media/lib/media-data.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ export const mediaData = {
5858

5959
const mediaData = { path, properties };
6060

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

6667
return mediaData;

0 commit comments

Comments
 (0)