Let's say i have one struct
pub struct Student {
name: String,
age: i32,
}
I have list of Student type & i want to insert it into postgres table in single query.
I am following this (UNNEST()
) it has egs for primitive type list but not for structs.
My code snippet
sqlx::query!(
"INSERT INTO students(name, age) SELECT * FROM UNNEST($1::text[], $2::int8[])",
&students[..]
)
.execute(&pool)
.await.unwrap();
What should i change in above code snippet to insert multiple rows at once?