JamalJ
Convex Community2y ago
6 replies
Jamal

Convex Rust Client (None Async) help

Hello, im writing a a web scrapper and i want to save some data to convex. I cant use async rust. So how can i use the convex base client to send some mutation data over to my convex server.

const MUTATION_QUERY_KEY: &str = "anime:createAnimeData";

fn save_to_database() {
    println!("Loading data from disk...");

    let mut data: Vec<AnimeData> = Vec::new();
    let files = std::fs::read_dir("anime").unwrap();

    for file in files {
        let path = file.unwrap().path();
        if path.is_file() {
            let contents = std::fs::read_to_string(path).unwrap();
            let json_data: AnimeData = serde_json::from_str(&contents).unwrap();
            data.push(json_data);
        }
    }

    println!("Sending data to convex server...");

    let client = BaseConvexClient::new();

    for anime in data {
        client.mutation(MUTATION_QUERY_KEY, maplit::btreemap! {});
    }

    println!("Done!");
}


Here is the code. However i have a few errors:

mismatched types
expected `UdfPath`, found `&str`


Why does the mutation take this type? Should it not be the key of the function?
Was this page helpful?