sea-orm-timescale
TimescaleDB extension for Sea-ORM.
Install
Query Functions
time_bucket
use ;
let bucket = time_bucket;
// SQL: time_bucket('1 hours', "time")
time_bucket_gapfill
use time_bucket_gapfill;
let bucket = time_bucket_gapfill;
// SQL: time_bucket_gapfill('1 hours', "time")
first / last
use ;
let earliest = first;
let latest = last;
locf (Last Observation Carried Forward)
use locf;
use *;
let filled = locf;
// SQL: locf(AVG("value"))
histogram
use histogram;
let dist = histogram;
// SQL: histogram("temperature", 0, 100, 10)
Migration Helpers
Create a hypertable
use ;
create_hypertable.await?;
Enable compression
use ;
enable_compression.await?;
Add retention policy
use ;
add_retention_policy.await?;
Create continuous aggregate
use ;
create_continuous_aggregate.await?;
Refresh continuous aggregate
use refresh_continuous_aggregate;
refresh_continuous_aggregate.await?;
Interval Parsing
Supports full and short formats:
use Interval;
// Full
parse; // Interval::Hours(1)
parse; // Interval::Minutes(5)
parse; // Interval::Days(7)
// Short
parse; // Interval::Hours(1)
parse; // Interval::Minutes(5)
parse; // Interval::Days(7)
parse; // Interval::Weeks(1)
parse; // Interval::Seconds(30)
parse; // Interval::Months(1)
Security
All identifier parameters are validated to prevent SQL injection:
validate_ident()— rejects non-alphanumeric/underscore identifiersescape_string_literal()— escapes single quotes in string values
License
MIT