Skip to content

Commit

Permalink
feat(endpoint-micropub): replace existing if creating a post with the…
Browse files Browse the repository at this point in the history
… same url
  • Loading branch information
paulrobertlloyd committed Oct 8, 2024
1 parent de80ab6 commit b3b0baa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/endpoint-micropub/lib/post-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ export const postData = {

const postData = { path, properties };

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

return postData;
Expand Down

0 comments on commit b3b0baa

Please sign in to comment.