#[drive(Collection, Views)]
#[collection(name="timer")]
#[view(TimerIsRunning, name = "timer_by_running", condition = |document| document.contents.running)] // Creates a View that emits all Documents where running = true
pub struct Timer {
#[view(TimerByRunning. name = "timer_by_running")] // Creates a View, that emits the key `running`
#[view(TimerIsRunning, name = "timer_by_running", when_eq = true)] // Creates a View that emits all Documents where running = true
pub running: bool
}
First argument to #[view(...)] would be the struct name of the view, following would be the properties.
Multiple attributes with the same struct name would be the same view.
I think there is more to add here, just some initial ideas. There is also probably a limit till where it makes sense to be able to derive it like so, and after which a custom implementation will be more sensible.
My idea would be to allow something like:
First argument to
#[view(...)]
would be the struct name of the view, following would be the properties.Multiple attributes with the same struct name would be the same view.
I think there is more to add here, just some initial ideas. There is also probably a limit till where it makes sense to be able to derive it like so, and after which a custom implementation will be more sensible.