-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
node/expressThis story primarily features node or express codeThis story primarily features node or express code
Description
User Story:
As a developer,
I want to be able to hit a backend route to add a palette to a user,
So that our users data is saved to the DB and can be synced
Acceptance Criteria:
- Create a new
PUTroute inindex.jsat the path "/save-palette" - Make sure that the callback function is
async. (Here's a good reference for this) - If
req.userexists, then we want to use thefindOneAndUpdatemethod on ourUserDB model- Use this documentation to build our
findOneAndUpdateDB query. - Because
palettesis an array, we can use the mongo$pushoperator to append our new palette to the array rather than replace the whole thing. - We also want to return the updated document from this route so that we can immediately display the newly added changes in the browser
- Use this documentation to build our
- Use Postman to test this new api endpoint (remember for this to work you'll need to be logged into Halogen or else there won't be a user in
req.user).
Note: When creating a REST API, the PUT route is used to update an existing document, while POST is used to create a new one.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
node/expressThis story primarily features node or express codeThis story primarily features node or express code