rdatatables

This is the "backend" implementation for the datatables AJAX api on rust-lang.

Follow this on how to use:

```rust /* Your datat structers */ use crate::models::rdatatables::{ ClerksViewListing, ClerksViewListingClerkInfo, ClerksViewListingStatusClerk, };

[post("/list", data = "")]

pub fn list( _adminitrative: AdminUser, query: LenientForm, ) -> Json< OutcomeData<( ClerksViewListing, ClerksViewListingStatusClerk, ClerksViewListingClerkInfo, )>,

{ Json(datatablesquery::<( ClerksViewListing, ClerksViewListingStatusClerk, ClerksViewListingClerkInfo, )>( Tables { origin: ("sysuser", "userid"), /* From / fields: vec![ "clerk_info.clerk_image", "sysuser.user_name", "sysuser.user_uni", "sysuser.user_balance", "status_clerk.is_available", "sysuser.user_status", "sysuser.user_id", ], / Fields to seek for / join_targets: Some(vec![ / If you desire to not do a Join at all, just give a None here / / (jointype, (target, targetkey), (origin, originkey) */ ("inner", ("clerkinfo", "userid"), ("sysuser", "userid")), ( "inner", ("statusclerk", "clerkid"), ("sysuser", "userid"), ), ]), datatablespostquery: query.intoinner(), /* Incoming Query parses to the desired struct. / query: None, / Our builded query holder */ }, crate::establish_connection(), )) } ```

/* ClerksViewListing (Implements joins) */

[derive(Debug, QueryableByName, Serialize, Clone)]

[table_name = "sysuser"]

pub struct ClerksViewListing { pub username: String, pub useruni: Option, pub userbalance: f64, pub userid: i32, }

[derive(Debug, QueryableByName, Serialize, Clone)]

[tablename = "statusclerk"]

pub struct ClerksViewListingStatusClerk { pub is_available: Option, }

[derive(Debug, QueryableByName, Serialize, Clone)]

[tablename = "clerkinfo"]

pub struct ClerksViewListingClerkInfo { pub clerk_image: Option, }

* Your front-end association with datatable must be something like this, do not forget about the "post" and "columns", js $('#clientsTable').DataTable({ "serverSide": true, "ordering": true, "info": true, "ajax": { url: "/admin/clerk/list", type: "POST" }, "columns": [ { "data": "1.clerkimage" }, { "data": "0.username" }, { "data": "0.useruni" }, { "data": "0.userbalance" }, { "data": "2.isavailable" }, { "data": "0.userstatus" }, { "data": "0.userid" }, /* Stands for userid */ ] });

```

Have fun. follow me on twitter: @luisvonmuller

I'm open to oportunities ;) luis@vonmuller.com.br

*this crate maybe open to SQL injections view the "search" field on the front-end datatables. This will be fixed as soon as possible. * Whats missing? * Regex searching * combinative column searching * Fixing performance issues over the iterator of column parser (By now the lib is parsing columns by an exaustive sequencial IF statement. Must be fixed.)