Macro update

Source
macro_rules! update {
    (connection => $connection:expr,model : $model:expr
    $(,select:{
        $($select:expr),*
    })?
      ,data:{
        $($from:expr => $data:expr),*
    }
    $(,conditions:{
        $(and => {$($conditions:expr => $value:expr),*})?
        $(,)?
        $(or => {$($conditions_or:expr => $value_or:expr),*})?
    })?
    ) => { ... };
    (connection => $connection:expr,
        model:$model:expr,
        match:$model_value:expr
        $(,select:{
            $($select:expr),*
        })?
        ,inside:
        {
            $from:expr => {
                match:$match:expr,
                $(conditions : {
                    $(and => {$($and_from_key:expr => $and_from_value:expr),*})?
                    $(,)?
                    $(or => {$($or_from_key:expr => $or_from_value:expr),*})?
                })?
                $(,)?
                data:{
                    $($data_from:expr => $data_value:expr),*
                }
                $(,)?
                $(
                    select:{
                    $(
                        $select_from:expr
                    ),*
                    }
                )?
            }
        }
        $(,conditions:{
            $(and => {$($conditions:expr => $value:expr),*})?
            $(or => {$($conditions_or:expr => $value_or:expr),*})?
        })?
        // $(

        // )?
        ) => { ... };
}
Expand description

§Example

let update = update! {
    connection => postgres,
    model:"place",
    select:{
        "id"
    },
    data:{
        "name" => "billionairehari"
    },
    conditions:{
        and => {
            "name" => "billionairehari"
        },
        or => {
            "" => ""
        }
    }
};

§Usage

let update = update! {
       connection => postgres,
       model:"billionaires",
       match:"id",
       inside:{
           "place"  => {
               match:"user_id",
               conditions:{
                   and => {
                       "name" => "billionaires",
                       "user_id" => "c4a97a50-8679-4f85-a1d8-5bba0113b596"
                   }
               },
               data:{
                   "name" => "billionairehari"
               },
               select:{
                   "name"
               }
           }
       }
   };