我有一个 Postgres 表,其中包含三个字段
id,即 a bigserial、metaajsonb字段和 uuidUUID字段。
pub struct MetaLogs {
pub id:i64,
pub uuid: <what type should I give here >
pub meta: < What type should I give here >
}
Run Code Online (Sandbox Code Playgroud)
我正在使用sqlxORM 进行Rust. 虽然我明白我必须添加
features = [ "runtime-tokio", "macros" ,"postgres","json","uuid"]
Run Code Online (Sandbox Code Playgroud)
我不知道之后如何继续
sqlx为 PostgreSQL提供Json和Uuid类型实现。请参阅uuid.rs和json.rs。
请注意,Json 类型将在内部解析为 jsonb,这正如您所期望的那样。
样本:
use sqlx::{types::Uuid, types::Json};
pub struct MetaLogs {
pub id: i64,
pub uuid: Uuid,
pub meta: Json,
}
Run Code Online (Sandbox Code Playgroud)