pub struct UserSession {
pub id: i32,
pub user_id: i32,
pub refresh_token: String,
pub device: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
Fields§
§id: i32
§user_id: i32
§refresh_token: String
§device: Option<String>
§created_at: DateTime<Utc>
§updated_at: DateTime<Utc>
Implementations§
Source§impl UserSession
impl UserSession
Sourcepub fn create(
db: &mut Connection,
item: &UserSessionChangeset,
) -> QueryResult<Self>
pub fn create( db: &mut Connection, item: &UserSessionChangeset, ) -> QueryResult<Self>
Create an entry in db
’s user_sessions
table using the data in item
§Errors
diesel::result::Error
if the query fails
Sourcepub fn read(db: &mut Connection, item_id: i32) -> QueryResult<Self>
pub fn read(db: &mut Connection, item_id: i32) -> QueryResult<Self>
Read from db
, querying for an entry in the user_sessions
who’s primary key matches item_id
§Errors
diesel::result::Error
if the query fails
Sourcepub fn find_by_refresh_token(
db: &mut Connection,
item_refresh_token: &str,
) -> QueryResult<Self>
pub fn find_by_refresh_token( db: &mut Connection, item_refresh_token: &str, ) -> QueryResult<Self>
Query db
’s user_sessions
table for an entry
who’s refresh_token
matches the given item_refresh_token
§Errors
diesel::result::Error
if the query fails
Sourcepub fn read_all(
db: &mut Connection,
pagination: &PaginationParams,
item_user_id: i32,
) -> QueryResult<Vec<Self>>
pub fn read_all( db: &mut Connection, pagination: &PaginationParams, item_user_id: i32, ) -> QueryResult<Vec<Self>>
Read from db
, return entries of the user_sessions
table,
paginated according to pagination
§Errors
diesel::result::Error
if the query fails
Sourcepub fn count_all(db: &mut Connection, item_user_id: i32) -> QueryResult<i64>
pub fn count_all(db: &mut Connection, item_user_id: i32) -> QueryResult<i64>
Query db
for all entries in the user_sessions
table
who’s user_id
matches the given [item_user_id
]
§Errors
diesel::result::Error
if the query fails
Sourcepub fn update(
db: &mut Connection,
item_id: i32,
item: &UserSessionChangeset,
) -> QueryResult<Self>
pub fn update( db: &mut Connection, item_id: i32, item: &UserSessionChangeset, ) -> QueryResult<Self>
Update the entry in db
’s user_sessions
table who’s primary key matches
item_id
, with the data in item
§Errors
diesel::result::Error
if the query fails
Sourcepub fn delete(db: &mut Connection, item_id: i32) -> QueryResult<usize>
pub fn delete(db: &mut Connection, item_id: i32) -> QueryResult<usize>
Delete the entry in db
’s user_sessions
table who’s
primary key matches item_id
§Errors
diesel::result::Error
if the query fails
Sourcepub fn delete_all_for_user(
db: &mut Connection,
item_user_id: i32,
) -> QueryResult<usize>
pub fn delete_all_for_user( db: &mut Connection, item_user_id: i32, ) -> QueryResult<usize>
Delete all entries in db
’s user_sessions
table who’s
‘user_id
’ matches item_user_id
§Errors
diesel::result::Error
if the query fails
Trait Implementations§
Source§impl<'update> AsChangeset for &'update UserSession
impl<'update> AsChangeset for &'update UserSession
Source§type Changeset = <(Grouped<Eq<user_id, <&'update i32 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<refresh_token, <&'update String as AsExpression<<refresh_token as Expression>::SqlType>>::Expression>>, Option<Grouped<Eq<device, <&'update String as AsExpression<<device as Expression>::SqlType>>::Expression>>>, Grouped<Eq<created_at, <&'update DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <&'update DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
type Changeset = <(Grouped<Eq<user_id, <&'update i32 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<refresh_token, <&'update String as AsExpression<<refresh_token as Expression>::SqlType>>::Expression>>, Option<Grouped<Eq<device, <&'update String as AsExpression<<device as Expression>::SqlType>>::Expression>>>, Grouped<Eq<created_at, <&'update DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <&'update DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
The update statement this type represents
Source§fn as_changeset(self) -> <Self as AsChangeset>::Changeset
fn as_changeset(self) -> <Self as AsChangeset>::Changeset
Convert
self
into the actual update statement being executedSource§impl AsChangeset for UserSession
impl AsChangeset for UserSession
Source§type Changeset = <(Grouped<Eq<user_id, <i32 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<refresh_token, <String as AsExpression<<refresh_token as Expression>::SqlType>>::Expression>>, Option<Grouped<Eq<device, <String as AsExpression<<device as Expression>::SqlType>>::Expression>>>, Grouped<Eq<created_at, <DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
type Changeset = <(Grouped<Eq<user_id, <i32 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<refresh_token, <String as AsExpression<<refresh_token as Expression>::SqlType>>::Expression>>, Option<Grouped<Eq<device, <String as AsExpression<<device as Expression>::SqlType>>::Expression>>>, Grouped<Eq<created_at, <DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
The update statement this type represents
Source§fn as_changeset(self) -> <Self as AsChangeset>::Changeset
fn as_changeset(self) -> <Self as AsChangeset>::Changeset
Convert
self
into the actual update statement being executedSource§impl<__FK> BelongsTo<&User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
impl<__FK> BelongsTo<&User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
Source§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
Source§type ForeignKeyColumn = user_id
type ForeignKeyColumn = user_id
The database column representing the foreign key
of the table this struct represents
Source§fn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for
self
Source§fn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table
Source§impl<__FK> BelongsTo<User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
impl<__FK> BelongsTo<User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
Source§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
Source§type ForeignKeyColumn = user_id
type ForeignKeyColumn = user_id
The database column representing the foreign key
of the table this struct represents
Source§fn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for
self
Source§fn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table
Source§impl Clone for UserSession
impl Clone for UserSession
Source§fn clone(&self) -> UserSession
fn clone(&self) -> UserSession
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UserSession
impl Debug for UserSession
Source§impl<'de> Deserialize<'de> for UserSession
impl<'de> Deserialize<'de> for UserSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl HasTable for UserSession
impl HasTable for UserSession
Source§impl<'ident> Identifiable for &'ident UserSession
impl<'ident> Identifiable for &'ident UserSession
Source§impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5), __DB> for UserSession
impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5), __DB> for UserSession
Auto Trait Implementations§
impl Freeze for UserSession
impl RefUnwindSafe for UserSession
impl Send for UserSession
impl Sync for UserSession
impl Unpin for UserSession
impl UnwindSafe for UserSession
Blanket Implementations§
Source§impl<'a, Parent, Child> BelongingToDsl<&'a Vec<Parent>> for Childwhere
Child: BelongingToDsl<&'a [Parent]>,
impl<'a, Parent, Child> BelongingToDsl<&'a Vec<Parent>> for Childwhere
Child: BelongingToDsl<&'a [Parent]>,
Source§type Output = <Child as BelongingToDsl<&'a [Parent]>>::Output
type Output = <Child as BelongingToDsl<&'a [Parent]>>::Output
The query returned by
belonging_to
Source§fn belonging_to(
parents: &'a Vec<Parent>,
) -> <Child as BelongingToDsl<&'a Vec<Parent>>>::Output
fn belonging_to( parents: &'a Vec<Parent>, ) -> <Child as BelongingToDsl<&'a Vec<Parent>>>::Output
Get the record(s) belonging to record(s)
other
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self
to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, ST, DB> StaticallySizedRow<ST, DB> for T
impl<T, ST, DB> StaticallySizedRow<ST, DB> for T
Source§const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE
const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE
The number of fields that this type will consume.