Rewrite from mongodb to sqlx (#1)

Reviewed-on: #1
This commit is contained in:
2025-07-20 13:16:31 +00:00
parent a58df1cb8e
commit 14c520c1d2
19 changed files with 814 additions and 1078 deletions

View File

@@ -1,26 +1,27 @@
use mongodb::bson::{doc, oid::ObjectId};
use serde::{Deserialize, Serialize};
use sqlx::prelude::FromRow;
#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, FromRow)]
pub struct OriginOrLocation {
pub name: String,
pub url: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, FromRow)]
pub struct Character {
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option<ObjectId>, // Mongo _id
pub id: i64,
pub rmid: i32, // Rick&Morty ID, don't confuse with _id
pub name: String,
pub status: String,
pub species: String,
pub r#type: String,
pub gender: String,
pub origin: OriginOrLocation,
pub location: OriginOrLocation,
pub origin_name: String,
pub origin_url: String,
pub location_name: String,
pub location_url: String,
pub image: String,
pub episode: Vec<String>,
pub episode: String,
pub url: String,
pub created: String,
pub elo_rating: f64,