Trait diesel::pg::expression::extensions::MicroIntervalDsl
[−]
[src]
pub trait MicroIntervalDsl: Sized + Mul<Self, Output = Self> {
fn microseconds(self) -> PgInterval;
fn milliseconds(self) -> PgInterval { ... }
fn seconds(self) -> PgInterval { ... }
fn minutes(self) -> PgInterval { ... }
fn hours(self) -> PgInterval { ... }
fn microsecond(self) -> PgInterval { ... }
fn millisecond(self) -> PgInterval { ... }
fn second(self) -> PgInterval { ... }
fn minute(self) -> PgInterval { ... }
fn hour(self) -> PgInterval { ... }
}A DSL added to i64 and f64 to construct PostgreSQL intervals of less
than 1 day.
The behavior of these methods when called on NAN or Infinity is
undefined.
Example
connection.execute("INSERT INTO users (name, created_at) VALUES ('Sean', NOW()), ('Tess', NOW() - '5 minutes'::interval), ('Jim', NOW() - '10 minutes'::interval)").unwrap(); let mut data: Vec<String> = users .select(name) .filter(created_at.gt(now - 7.minutes())) .load(&connection).unwrap(); assert_eq!(2, data.len()); assert_eq!("Sean".to_string(), data[0]); assert_eq!("Tess".to_string(), data[1]);
Required Methods
fn microseconds(self) -> PgInterval
Returns a PgInterval representing self as microseconds
Provided Methods
fn milliseconds(self) -> PgInterval
Returns a PgInterval representing self as milliseconds
fn seconds(self) -> PgInterval
Returns a PgInterval representing self as seconds
fn minutes(self) -> PgInterval
Returns a PgInterval representing self as minutes
fn hours(self) -> PgInterval
Returns a PgInterval representing self as hours
fn microsecond(self) -> PgInterval
Identical to microseconds
fn millisecond(self) -> PgInterval
Identical to milliseconds
fn second(self) -> PgInterval
Identical to seconds
fn minute(self) -> PgInterval
Identical to minutes
fn hour(self) -> PgInterval
Identical to hours