Crates.io | reactive-pg |
lib.rs | reactive-pg |
version | 0.2.0 |
source | src |
created_at | 2023-02-03 13:04:18.586883 |
updated_at | 2023-02-03 13:04:18.586883 |
description | Reactive Postgres layer for rust |
homepage | |
repository | https://github.com/Champii/reactive-postgres-rs |
max_upload_size | |
id | 775542 |
size | 15,390 |
Watch your queries results change as new rows are inserted/updated/deleted
Work in progress
This little example connects to localhost as user postgres. This will be configurable.
use reactive_pg::*;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct Foo {
id: i32,
name: String,
}
#[tokio::main]
async fn main() {
"SELECT * from foo where id < 10"
.watch::<Foo>(|event| println!("{:#?}", event))
.await
.await // <- The second await will block until the connection is dropped
.unwrap();
}