add first draft of logbook
This commit is contained in:
@ -85,6 +85,21 @@ ORDER BY last_access DESC
|
||||
.unwrap() //TODO: fixme
|
||||
}
|
||||
|
||||
pub async fn cox(db: &SqlitePool) -> Vec<Self> {
|
||||
sqlx::query_as!(
|
||||
User,
|
||||
"
|
||||
SELECT id, name, pw, is_cox, is_admin, is_guest, deleted, last_access
|
||||
FROM user
|
||||
WHERE deleted = 0 AND is_cox=true
|
||||
ORDER BY last_access DESC
|
||||
"
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap() //TODO: fixme
|
||||
}
|
||||
|
||||
pub async fn create(db: &SqlitePool, name: &str, is_guest: bool) -> bool {
|
||||
sqlx::query!(
|
||||
"INSERT INTO USER(name, is_guest) VALUES (?,?)",
|
||||
@ -365,6 +380,13 @@ mod test {
|
||||
assert!(res.len() > 3);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_cox() {
|
||||
let pool = testdb!();
|
||||
let res = User::cox(&pool).await;
|
||||
assert_eq!(res.len(), 2);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_succ_create() {
|
||||
let pool = testdb!();
|
||||
|
Reference in New Issue
Block a user