mgroves / realworld-aspnet-couchbase

Conduit implementation: ASP.NET Core + Couchbase
https://realworld.io
MIT License
12 stars 4 forks source link

Endpoint: Update Article #17

Open mgroves opened 1 year ago

mgroves commented 1 year ago

PUT /api/articles/:slug

Example request body:

{
  "article": {
    "title": "Did you train your dragon?"
  }
}

Authentication required, returns the updated Article

Optional fields: title, description, body

The slug also gets updated when the title is changed

mgroves commented 1 year ago

Probably need a transaction to create new article and delete old article.

What happens to any favorites of the previous slug? Updating them ALL is probably too much work for a single endpoint?

mgroves commented 1 year ago

Scratch that comment, here's the approach I'm taking:

in this implementation, slug is doing double duty! each slug is of the form "my-title::xyxyxyx" where the "my-title" part is derived from the title and the xyxyxyx part is generated and used as the unique document key SO THAT the title and slug can be mutable WITHOUT having to create a copy of the article AND all the references in favorites documents remain the same

ONLY use GetArticleKey extension WITHIN the data access portions of the application OR within tests/test helpers