MCPcopy Create free account
hub / github.com/chatmail/core / query_map

Method query_map

src/sql.rs:352–371  ·  view source on GitHub ↗

Prepares and executes the statement and maps a function over the resulting rows. Then executes the second function over the returned iterator and returns the result of that function.

(
        &self,
        sql: &str,
        params: impl rusqlite::Params + Send,
        f: F,
        g: G,
    )

Source from the content-addressed store, hash-verified

350 /// Then executes the second function over the returned iterator and returns the
351 /// result of that function.
352 pub async fn query_map<T, F, G, H>(
353 &self,
354 sql: &str,
355 params: impl rusqlite::Params + Send,
356 f: F,
357 g: G,
358 ) -> Result<H>
359 where
360 F: Send + FnMut(&rusqlite::Row) -> Result<T>,
361 G: Send + FnOnce(rusqlite::AndThenRows<F>) -> Result<H>,
362 H: Send + 'static,
363 {
364 let query_only = true;
365 self.call(query_only, move |conn| {
366 let mut stmt = conn.prepare(sql)?;
367 let res = stmt.query_and_then(params, f)?;
368 g(res)
369 })
370 .await
371 }
372
373 /// Prepares and executes the statement and maps a function over the resulting rows.
374 ///

Callers 15

get_allMethod · 0.80
from_msgMethod · 0.80
query_map_collectMethod · 0.80
remove_unused_filesFunction · 0.80
maybe_add_from_paramFunction · 0.80
get_chat_msgs_exFunction · 0.80
shall_attach_selfavatarFunction · 0.80
get_kmlFunction · 0.80
try_loadMethod · 0.80

Calls 2

callMethod · 0.80
prepareMethod · 0.45

Tested by

no test coverage detected