new sort option
This commit is contained in:
@@ -361,6 +361,13 @@ WHERE lower(name)=lower(?)
|
||||
}
|
||||
|
||||
pub async fn all_with_order(db: &SqlitePool, sort: &str, asc: bool) -> Vec<Self> {
|
||||
let allowed_sort_columns = ["last_access", "name", "member_since_date"];
|
||||
let sort_column = if allowed_sort_columns.contains(&sort) {
|
||||
sort
|
||||
} else {
|
||||
"last_access"
|
||||
};
|
||||
|
||||
let mut query = format!(
|
||||
"
|
||||
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, phone, address, family_id, user_token
|
||||
@@ -368,7 +375,7 @@ WHERE lower(name)=lower(?)
|
||||
WHERE deleted = 0
|
||||
ORDER BY {}
|
||||
",
|
||||
sort
|
||||
sort_column
|
||||
);
|
||||
if !asc {
|
||||
query.push_str(" DESC");
|
||||
|
||||
Reference in New Issue
Block a user