Dependencies and start the application copy amazing your application should be running on. The starting project has the following folder structure. Currently the project uses dummy data in a file to display published posts on a route and unpublished posts on a route. You currently cannot view individual posts and register as a user or create draft post. You will use the functions and to implement these functions later in this guide. Additionally you will replace fetching data from dummy data with a database. Now it’s time to get started with the setup. First install as development dependencies using the following command. Copy Create a new post in the database. Create a file inside the folder and add the following code. Copy the above code snippet. Do the following. Declare an action to create a new post in the database.
Create a new post in . to read data f photo editing servies rom the form. Add validation checks for any missing required inputs. This function will return a status code and data to the client. Add type checking for entries with non-string values. Query the database using the request body Expecting required Post title Required Post content Required The email of the user who created the post The user should already exist After executing the query throws a redirect to the route. Click the button and fill out the form to create a new post. Your post should appear on the route after submission. To publish and delete posts by it add the following code in the existing file inside the folder copy the code snippet do the following import and utility. Action defines a query to find posts and updates the published attribute to.
Action defines a query to delete posts by posts. Select any unpublished post and you should be able to delete or publish it. You should also be able to delete published posts. Create a new user Create a file inside the folder and add the following code Copy this code Do the following This action receives the data submitted from the registration form. Check if any required input is missing and the user email is valid. Add type checking for entries with non-string values. Add verification check for user email. Create a new user using the following request body Required Username Required User's email address Select the button and fill out the form. You should now be able to add new users to the database. Congratulations you are done. You have successfully added a query to change data in the.