pub async fn create_poll(pool: &DBPool, user_id: i32, title: String, description: String) -> Result<Poll> {
        if title.len() < 1 || title.len() > 255 {
            generic_err!("Title must be between 1 and 255 characters")
        } else if description.len() > 1023 {
            generic_err!("Description must be no more than 1023 characters")
        } else {
            let mut res = generic_service_err!(
                sqlx::query_file_as!(Poll, "sql/poll/create_poll.sql", user_id, title, description)
                .fetch_all(pool).await,
                "Failed to create new poll");

            Ok(res.remove(0))
        }
    }
/// Creates a poll and returns the resulting record
/// 
/// # Arguments
/// 
/// * `pool` - The database pool
/// * `user_id` - The ID of the user creating the poll
/// * `title` - The poll title
/// * `description` - The poll description
Creates a poll and returns the resulting record
Creates a poll and returns the resulting record
pub async fn create_poll(pool: &DBPool, user_id: i32, title: String, description: String) -> Result<Poll> {
        if title.len() < 1 || title.len() > 255 {
            generic_err!("Title must be between 1 and 255 characters")
        } else if description.len() > 1023 {
            generic_err!("Description must be no more than 1023 characters")
        } else {
            let mut res = generic_service_err!(
                sqlx::query_file_as!(Poll, "sql/poll/create_poll.sql", user_id, title, description)
                .fetch_all(pool).await,
                "Failed to create new poll");
            Ok(res.remove(0))
        }
    }
pub async fn create_poll ( pool : & DBPool , user_id : i32 , title : String , description : String ) -> Result < Poll > { if title . len ( ) < 1 || title . len ( ) > 255 { generic_err ! ( " " ) } else if description . len ( ) > 1023 { generic_err ! ( " " ) } else { let mut res = generic_service_err ! ( sqlx query_file_as ( Poll " " user_id title description ) fetch_all ( pool ) await " " ) ; Ok ( res . remove ( 0 ) ) } }
Creates a poll and returns the resulting record
Creates a poll and returns the resulting record
pool
&DBPool
user_id
i32
title
String
description
String
pool
&DBPool
user_id
i32
title
String
description
String