Nested structs? struct Metadata { created_at: SystemTime, updated_at: SystemTime }
#5061
Answered
by
weiznich
kairoswater-jason
asked this question in
Q&A
BackendPostgreSQL Diesel version2.3 Diesel Featurespostgres, uuid, chrono, serde Operating System VersionNo response Third party librariesNo response What do you want to do?I did a quick search and didn't see anything about this. What do I have to do (if anything) to enable me to INSERT and SELECT structs like I assume it probably is nontrivial and infeasible, but I feel obligated to ask. CREATE TABLE my_table (
id uuid,
created_at timestamptz,
updated_at timestamptz.
foo text,
bar text
);struct Metadata {
created_at: SystemTime,
updated_at: SystemTime,
}
struct MyTable {
id: Uuid,
metadata: Metadata,
foo: String,
bar: String,
}Above is just a simple example, in reality a metadata struct would likely contain many more fields (created_by, updated_by, etc.) Thanks! Compile time errorNo response What code do you already have?No response Additional detailsNo response Checklist
|
Answered by
weiznich
May 28, 2026
Replies: 1 comment
|
You want to use |
0 replies
Answer selected by
kairoswater-jason
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You want to use
#[diesel(embed)]. See the API docs for#[derive(Insertable)]and#[derive(AsChangeset)]for details