rsiot/components/cmp_timescaledb/model/
row.rs1use sqlx::{types::time::OffsetDateTime, FromRow};
4
5use super::agg_type::AggType;
6
7#[derive(Debug, FromRow)]
9pub struct Row {
10 pub time: OffsetDateTime,
12 pub entity: String,
14 pub attr: String,
16 pub value: f64,
18 pub agg: AggType,
20 pub aggts: Option<OffsetDateTime>,
22 pub aggnext: Vec<AggType>,
24}
25
26impl Row {
27 pub fn new_simple(entity: &str, attr: &str, value: f64) -> Self {
29 Self {
30 time: OffsetDateTime::now_utc(),
31 entity: entity.to_string(),
32 attr: attr.to_string(),
33 value,
34 agg: AggType::Curr,
35 aggts: None,
36 aggnext: vec![],
37 }
38 }
39}