我有一个 Postgres 表,其中包含三个字段
id
,即 a bigserial
、meta
ajsonb
字段和 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)
我正在使用sqlx
ORM 进行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)
归档时间: |
|
查看次数: |
4978 次 |
最近记录: |