I have this:
pub fn is_token_valid(conn: &mut SqliteConnection, id: String) -> bool {
use crate::diesel::schema::users::dsl::session_id;
use crate::diesel::schema::users::dsl::users;
use diesel::OptionalExtension;
let user_with_session_id = users.filter(session_id.eq(id)).first::<User>(conn);
todo!()
}
I want to search the database to see if a user has this session id, and if it finds it, return true, otherwise return false.
but it just gives me awful error messages:
error[E0277]: the trait bound `(diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text, diesel::sql_types::Timestamp, diesel::sql_types::Nullable<diesel::sql_types::Text>): load_dsl::private::CompatibleType<User, Sqlite>` is not satisfied
|
58 | let user_with_session_id = users.filter(session_id.eq(id)).first::<User>(conn);
| ----- ^^^^ the trait `load_dsl::private::CompatibleType<User, Sqlite>` is not implemented for `(diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text, diesel::sql_types::Timestamp, diesel::sql_types::Nullable<diesel::sql_types::Text>)`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `load_dsl::private::CompatibleType<U, DB>`:
(ST0, ST1)
(ST0, ST1, ST2)
(ST0, ST1, ST2, ST3)
(ST0, ST1, ST2, ST3, ST4)
(ST0, ST1, ST2, ST3, ST4, ST5)
(ST0, ST1, ST2, ST3, ST4, ST5, ST6)
(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7)
(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8)
and 24 others
I also have tried using .limit(1) but had no luck either