mysql_macros 0.1.2

Provides simple macro(s) to help when developing with mysql
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 2.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 971.01 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Muqito/mysql_macros
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Muqito

About

This is just a quick macro to minimize the amount of maps you do with rust-mysql-simple (shoutout to an amazing library)

from this:

    let result = connection.prep_exec(
        "SELECT id, email, password FROM users WHERE email = :email",
        mysql::params! {
            "email" => username
        }
    ).map(|result| {
        result
            .map(|x| x.unwrap())
            .map(|row| {
               let (id, email, password) = mysql::from_row(row);
                User {
                    id,
                    email,
                    password
                }
            })
            .collect()
    });

to this:

    let result = mysql_macros::mysql_query!(connection,
        "SELECT id, email, password FROM users WHERE email = :email",
        mysql::params!(
            "email" => username
        ),
        |(id, email, password)| {
            User {
                id,
                email,
                password
            }
        }
    );

Image of code you will be able to reduce from