Permalink
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
Cannot retrieve contributors at this time.
Cannot retrieve contributors at this time
| use async_std::task::{self, block_on}; | |
| use futures::StreamExt; | |
| use orientdb_client::aio::OrientDB; | |
| use orientdb_client::OrientResult; | |
| fn main() -> OrientResult<()> { | |
| block_on(async { | |
| let client = OrientDB::connect(("localhost", 2424)).await?; | |
| let session = client.session("demodb", "admin", "admin").await?; | |
| let (unsubscriber, mut stream) = session.live_query("select from V").run().await?; | |
| task::spawn(async move { | |
| let _ = session | |
| .command("insert into V set id = 1") | |
| .run() | |
| .await | |
| .expect("Failed to run the query"); | |
| unsubscriber | |
| .unsubscribe() | |
| .await | |
| .expect("Failed to unsbubscrbe the live query"); | |
| }); | |
| while let Some(item) = stream.next().await { | |
| println!("Event {:?}", item?); | |
| } | |
| Ok(()) | |
| }) | |
| } |