As a developer,
I want to connect to a MongoDB database and implement the ability to create and read emotion types,
so that I can manage emotions efficiently.
Description
Set up a MongoDB connection and implement create and read functionality for emotion types.
The goal is to make emotion types easily accessible throughout the app by avoiding prop drilling and ensuring efficient data retrieval through filters. Information about emotion types should be loaded through a centralized filter, allowing for better performance and maintainability.
Acceptance criteria
[ ] Emotion types should be fetched from the MongoDB database and available for use across all relevant components without passing them through props at each level.
[ ] If no emotion types are available, the system should provide a clear message (e.g., “No emotion types available”).
[ ] The system should allow adding new emotion types to the MongoDB database.
[ ] Information should be loaded through a centralized filter to avoid unnecessary fetching and prop drilling.
[ ] Error handling should be in place if there is an issue with connecting to the database or fetching data.
Tasks
[ ] Create a new branch: feature/backendCreateRead.
[ ] Install the mongoose package to enable interaction with MongoDB.
[ ] Create a .env.local file and configure it with the necessary environment variables, including the MongoDB connection string and the collection for remedies.
[ ] Write a Schema in the corresponding file placed in the db/models folder
[ ] Implement an async handler function with a GET method
[ ] Perform a POST HTTP request with fetch.
[ ] Install the swr package to handle data fetching and caching.
[ ] Tell useSWR to revalidate the data by calling the mutate function
[ ] Implement error handling to manage database connection failures
Value proposition
As a developer, I want to connect to a MongoDB database and implement the ability to create and read emotion types, so that I can manage emotions efficiently.
Description
Set up a MongoDB connection and implement create and read functionality for emotion types. The goal is to make emotion types easily accessible throughout the app by avoiding prop drilling and ensuring efficient data retrieval through filters. Information about emotion types should be loaded through a centralized filter, allowing for better performance and maintainability.
Acceptance criteria
Tasks
fetch
.swr
package to handle data fetching and caching.useSWR
to revalidate the data by calling the mutate function