filemaker_search_results_output/
filemaker_search_results_output.rs

1use anyhow::Result;
2use filemaker_lib::Filemaker;
3use serde_json::Value;
4use std::collections::HashMap;
5
6#[tokio::main]
7async fn main() -> Result<()> {
8    Filemaker::set_fm_url("https://fm.example.com/fmi/data/vLatest")?; // Replace with actual filemaker server url
9    let username = "your_username";
10    let password = "your_password";
11    let database = "your_database";
12    let table = "your_table";
13    let filemaker = Filemaker::new(username, password, database, table).await?;
14
15    // Construct search query
16    let mut query = HashMap::new();
17    query.insert("fieldName".to_string(), "example_value".to_string()); // Replace "fieldName" and "example_value"
18
19    // Sorting criteria
20    let sort_fields = vec!["fieldName".to_string()]; // Replace with the field name to sort
21    let ascending = true;
22
23    let records = filemaker
24        .search::<Value>(vec![query], sort_fields, ascending, Some(10))
25        .await?;
26    println!("Search Results:");
27    for record in records.response.data {
28        println!("{:?}", record);
29    }
30
31    Ok(())
32}