1use serde::{Deserialize, Serialize};
2use start::db::query::filtering::{Filter, Value};
3
4type HandleResult<T> = Result<T, Box<dyn std::error::Error>>;
5
6#[derive(Serialize, Deserialize, Debug)]
7struct Agent {
8 name: String,
9 r#type: String,
10 score: i32,
11}
12
13fn main() -> HandleResult<()> {
14 let db = start::db_embedded("file.db".into())?;
15 let session = db.get_session();
16
17 session.start_transaction()?;
18
19 session.insert("agents",
20 &Agent {name: "Cloude".to_string(), r#type: "AI".to_string(), score: 88})?;
21 session.insert("agents",
22 &Agent {name: "ChatGPT".to_string(), r#type: "AI".to_string(), score: 90})?;
23 session.insert("agents",
24 &Agent {name: "Gemini".to_string(), r#type: "AI".to_string(), score: 85})?;
25
26 let result: Vec<Agent> = session.find()
27 .filter(Filter::Gt("score".into(), Value::Integer(85)))
28 .from("agents")?;
29 for entry in result {
30 println!("Entry: {:?}", entry);
31 }
32
33 session.commit_transaction()?;
37 Ok(())
38}