- 註冊時間
- 2023-12-26
- 最後登錄
- 2023-12-26
- 閱讀權限
- 10
- 積分
- 20
- 精華
- 0
- 帖子
- 1
該用戶從未簽到
|
How to use the loading and manipulation functions to build a simple blogging application. You will be adding a database and an existing application that currently only stores data in memory. technologies As a framework for migrations and queries As a programming language As a database Prerequisites To successfully complete this guide you need to install. If it's your editor you can install extensions to improve the developer experience by adding syntax highlighting, formatting and autocomplete on schema files. Set up your starter project first navigate to a directory of your choice and run the following commands to clone the repository copy install 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 indi photo editing servies vidual posts and register as a user or create draft post. You will use the functions and to implement these functions later in this guide. Addi tionally you will replace fetching data from dummy data with a database. Now it’s time to get started with the setup. First use the following command to install the development dependencies. Copy the load function to provide data when rendering the component. The loading function performs the request to the route. For this project you will implement the following load function Route description with load function Get all published posts Get all draft posts Get all published posts by getting a single post Create a file inside the folder and add the following code Copy the above function Do the following using options to query all published posts including their authors. Currently the client is still using dummy data from the database.
Replace the code with the following to correct this issue Copy the response returned from the load function answer. Iterates through the list of values subsequently displayed through the component. You can try this further by adding a post and setting the published property to . It should appear as part of the published post on the route. Get all draft posts Create a file inside the folder and add the following code Copy the function above Do the following Query all unpublished posts including their author relationship. Return object response. Similar to the previous step you will connect the client to the database instead of the file. Replace the existing code with the following code to copy the response returned from the load function. Iterates through the list of values subsequently displayed through the component. To get a single post, create a file inside the folder and add the following code. Copy .
|
|