Something went wrong. Try again.
Highly ambitious ATProtocol AppView service and sdks forked from slices.network/slices
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889//! 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 multiple types of operations:/// - `eq`: Exact match (field = value)/// - `in_values`: Array membership (field IN (...))/// - `contains`: Pattern matching (field ILIKE '%value%')/// - `fuzzy`: Fuzzy text matching (field % value)/// - `gt`: Greater than (field > value)/// - `gte`: Greater than or equal (field >= value)/// - `lt`: Less than (field < value)/// - `lte`: Less than or equal (field <= 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>, pub fuzzy: Option<String>, pub gt: Option<Value>, pub gte: Option<Value>, pub lt: Option<Value>, pub lte: Option<Value>,}
/// Represents a complete WHERE clause with AND/OR conditions.////// Supports both flat conditions (legacy) and nested and/or arrays (new)./// 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.////// New nested format supports arbitrarily nestable and/or:/// ```json/// {/// "and": [/// {/// "or": [/// { "artist": { "contains": "pearl jam" } },/// { "genre": { "contains": "rock" } }/// ]/// },/// {/// "and": [/// { "uri": { "contains": "app.bsky" } },/// { "uri": { "contains": "post" } }/// ]/// },/// { "year": { "gte": 2000 } }/// ]/// }/// ```#[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>>,
/// Nested AND conditions - array of WhereClause objects all ANDed together #[serde(rename = "and", skip_serializing_if = "Option::is_none")] pub and: Option<Vec<WhereClause>>,
/// Nested OR conditions - array of WhereClause objects all ORed together #[serde(rename = "or", skip_serializing_if = "Option::is_none")] pub or: Option<Vec<WhereClause>>,}
/// 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,}