Skip to main content

array

Function array 

Source
pub fn array<I: IntoIterator>(iter: I) -> Array<I::IntoIter>
where I::Item: ToSql + StaticType,
Expand description

Binds a lazy iterator as a one-dimensional PostgreSQL array.

Use this inside a query macro argument for UNNEST / = ANY:

ⓘ
let rows = query!(
    "SELECT id, name FROM users WHERE id = ANY($1::uuid[])",
    postgresql::array(uuids.iter()))
.fetch_all::<_, (uuid::Uuid, String)>(&db)
.await?;