surrealpatch/core/src/sql/v2/changefeed.rs
Przemyslaw Hugh Kaznowski 99600d50ba
Add syntax for change feeds to store original value alongside change (#3567)
Co-authored-by: Mees Delzenne <DelSkayn@users.noreply.github.com>
2024-02-28 19:35:39 +00:00

32 lines
743 B
Rust

use crate::sql::duration::Duration;
use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use std::str;
use std::time;
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 2)]
pub struct ChangeFeed {
pub expiry: time::Duration,
#[revision(start = 2)]
pub store_original: bool,
}
impl Display for ChangeFeed {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "CHANGEFEED {}", Duration(self.expiry))?;
if self.store_original {
write!(f, " INCLUDE ORIGINAL")?;
};
Ok(())
}
}
impl Default for ChangeFeed {
fn default() -> Self {
Self {
expiry: time::Duration::from_secs(0),
store_original: false,
}
}
}