Closed kakserpom closed 1 month ago
Hello, thanks for feedback.
Charybdis is only intended for server side use. Saying it's SSR only might be misleading as it's not relevant for the ORM which is used for server-side operations. You can design your app to be CSR or SSR regardless of the ORM you use. Given that client and server side have different requirements, charybdis types are not designed to run in client side WASM env as it doesn't need majority of the traits that are required by database driver itself. However, most of the types are aliases to rust types anyway, you can just map them if needed:
use bigdecimal::BigDecimal;
use chrono::{NaiveDate, Utc};
use std::collections::{HashMap, HashSet};
use std::net::IpAddr;
pub type Ascii = String;
pub type BigInt = i64;
pub type Boolean = bool;
pub type Blob = Vec<u8>;
pub type Date = NaiveDate;
pub type Decimal = BigDecimal;
pub type Double = f64;
pub type Float = f32;
pub type Inet = IpAddr;
pub type Int = i32;
pub type SmallInt = i16;
pub type Text = String;
pub type Time = chrono::NaiveTime;
pub type Timestamp = chrono::DateTime<Utc>;
pub type TinyInt = i8;
pub type Uuid = uuid::Uuid;
pub type Varchar = String;
pub type Varint = BigInt;
// collections
pub type Map<K, V> = HashMap<K, V>;
pub type List<T> = Vec<T>;
pub type Set<T> = HashSet<T>;
pub type Tuple<T1, T2> = (T1, T2);
Also for counter you can probably use just i64
.
pub type Counter = i64
For duration:
pub struct Duration {
pub months: i32,
pub days: i32,
pub nanoseconds: i64,
}
And my guess is that for Timeuuid you could just use uuid::Uuid
depending on the features that you need.
@GoranBrkuljan I know that Charybdis is only for server-side use. However, I would like to use same entity structures on the client side. There is no std::net::IpAddr
for obvious reasons. There are also some implementations in types.rs which are not needed.
Yep, I think that types sent in my prev responses should be enough. Main reasons we use aliases and few types implementation is additional serde support (for types that don't have it) and mapping for automatic migration tool. On client side you can even use native rust types (Strings, f64, and so on) as you don't need db traits. IpAddr
might be only exception to that, but you can have your own implementation if needed.
Hello! First of all thanks for a great project. I am using Leptos and I want to use same structs in WASM frontend. I cannot do that because Charybdis in an ssr-only dependency and
charybdis::types
is unavailable.