pub struct RowSet {
pub columns: Vec<Column>,
pub rows: Vec<Row>,
}Expand description
The result of a database query.
§Examples
Load a set of rows from a local PostgreSQL database, and iterate over them selecting one field from each. The columns collection allows you to find column indexes for column names; you can bypass this lookup if you name specific columns in the query.
use spin_sdk::pg3::{Connection, Decode};
let db = Connection::open("host=localhost user=postgres password=my_password dbname=mydb")?;
let query_result = db.query(
"SELECT * FROM users WHERE age >= $1",
&[min_age.into()]
)?;
let name_index = query_result.columns.iter().position(|c| c.name == "name").unwrap();
for row in &query_result.rows {
let name = String::decode(&row[name_index])?;
println!("Found user {name}");
}A set of database rows
Fields§
§columns: Vec<Column>§rows: Vec<Row>Trait Implementations§
Auto Trait Implementations§
impl Freeze for RowSet
impl RefUnwindSafe for RowSet
impl Send for RowSet
impl Sync for RowSet
impl Unpin for RowSet
impl UnwindSafe for RowSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more