MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / sql

Function sql

crates/client-api/src/routes/database.rs:759–779  ·  view source on GitHub ↗
(
    State(worker_ctx): State<S>,
    Path(name_or_identity): Path<SqlParams>,
    Query(params): Query<SqlQueryParams>,
    Extension(auth): Extension<SpacetimeAuth>,
    body: String,
)

Source from the content-addressed store, hash-verified

757}
758
759pub async fn sql<S>(
760 State(worker_ctx): State<S>,
761 Path(name_or_identity): Path<SqlParams>,
762 Query(params): Query<SqlQueryParams>,
763 Extension(auth): Extension<SpacetimeAuth>,
764 body: String,
765) -> axum::response::Result<impl IntoResponse>
766where
767 S: NodeDelegate + ControlStateDelegate + Authorization,
768{
769 let caller_identity = auth.claims.identity;
770 let caller_auth: ConnectionAuthCtx = auth.into();
771 let json = sql_direct(worker_ctx, name_or_identity, params, caller_identity, caller_auth, body).await?;
772
773 let total_duration = json.iter().fold(0, |acc, x| acc + x.total_duration_micros);
774
775 Ok((
776 TypedHeader(SpacetimeExecutionDurationMicros(Duration::from_micros(total_duration))),
777 axum::Json(json),
778 ))
779}
780
781#[derive(Deserialize)]
782pub struct DNSParams {

Callers 14

index.tsFile · 0.85
index.tsFile · 0.85
index.tsFile · 0.85
index.tsFile · 0.85
updateUnreadCountsFunction · 0.85
rpcVerifyFunction · 0.85
rpcSeedFunction · 0.85
rpcVerifyFunction · 0.85
rpcSeedFunction · 0.85
rpcVerifyFunction · 0.85
rpcSeedFunction · 0.85

Calls 4

sql_directFunction · 0.85
iterMethod · 0.65
OkFunction · 0.50

Tested by

no test coverage detected