Add Review Table to Rust Backend and migrated
Co-authored-by: Reimar <mail@reim.ar>
This commit is contained in:
		
							parent
							
								
									9a0757922d
								
							
						
					
					
						commit
						f8b3c3e1fc
					
				
							
								
								
									
										12
									
								
								rust-backend/migrations/V3__create_reviews_table.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								rust-backend/migrations/V3__create_reviews_table.sql
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| CREATE TABLE reviews ( | ||||
| 	id INTEGER PRIMARY KEY AUTOINCREMENT, | ||||
| 	user_id TEXT NOT NULL, | ||||
| 	lat REAL NOT NULL, | ||||
| 	lng REAL NOT NULL, | ||||
|     place_name TEXT NOT NULL, | ||||
|     place_description TEXT NOT NULL, | ||||
|     title TEXT NOT NULL, | ||||
|     content TEXT NOT NULL, | ||||
|     rating REAL NOT NULL | ||||
| ); | ||||
| 
 | ||||
| @ -25,3 +25,32 @@ impl Favorite { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[derive(Serialize)] | ||||
| pub struct Review { | ||||
|     pub id: i64, | ||||
|     pub user_id: String, | ||||
|     pub lat: f64, | ||||
|     pub lng: f64, | ||||
|     pub place_name: String, | ||||
|     pub place_description: String, | ||||
|     pub title: String, | ||||
|     pub content: String, | ||||
|     pub rating: i64, | ||||
| } | ||||
| 
 | ||||
| impl Review { | ||||
|     pub fn from_row(row: &Row) -> Result<Self, Error> { | ||||
|         Ok(Review { 
 | ||||
|             id: row.get("id")?, | ||||
|             user_id: row.get("user_id")?, | ||||
|             lat: row.get("lat")?, | ||||
|             lng: row.get("lng")?, | ||||
|             place_name: row.get("place_name")?, | ||||
|             place_description: row.get("place_description")?, | ||||
|             title: row.get("title")?, | ||||
|             content: row.get("content")?, | ||||
|             rating: row.get("rating")?, | ||||
|         }) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user