Create Resource
Learn to add code to insert data in the database.
We'll cover the following...
We'll cover the following...
Create a product
We can start creating the migration needed for our project. We can name it however we want. Let’s call it create_products to add the migration necessary to create and drop our table.
Note: After we install and configure Diesel according to the first Appendix, we can write the following command in a terminal window:
The previous command will create two files named up.sql and down.sql inside the migrations folder.
We’ll enter the below code in the up.sql file.
Let’s work with the down.sql file now.
Now, we can run our migration to create the products table by running the following command in the terminal:
We add a file called models.rs for our ...