Something went wrong. Try again.
A fork of @slices.network/slices forked from slices.network/slices
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061//! Database query parameter types.//!//! This module contains types used for building dynamic SQL queries,//! including WHERE conditions, sorting, and filtering.
use serde::{Deserialize, Serialize};use serde_json::Value;use std::collections::HashMap;
/// Represents a single condition in a WHERE clause.////// Supports three types of operations:/// - `eq`: Exact match (field = value)/// - `in_values`: Array membership (field IN (...))/// - `contains`: Pattern matching (field ILIKE '%value%')#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct WhereCondition { pub eq: Option<Value>, #[serde(rename = "in")] pub in_values: Option<Vec<Value>>, pub contains: Option<String>,}
/// Represents a complete WHERE clause with AND/OR conditions.////// The main conditions map is combined with AND logic./// The or_conditions map (if present) is combined with OR logic/// and the entire OR group is ANDed with the main conditions.////// Example JSON:/// ```json/// {/// "collection": {"eq": "app.bsky.feed.post"},/// "author": {"eq": "did:plc:123"},/// "$or": {/// "lang": {"eq": "en"},/// "lang": {"eq": "es"}/// }/// }/// ```#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct WhereClause { #[serde(flatten)] pub conditions: HashMap<String, WhereCondition>,
#[serde(rename = "$or")] pub or_conditions: Option<HashMap<String, WhereCondition>>,}
/// Represents a field to sort by with direction.////// Used for multi-field sorting in queries.#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct SortField { pub field: String, pub direction: String,}