Struct create_rust_app::auth::UserSession
source · 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>
sourcepub fn read(db: &mut Connection, item_id: i32) -> QueryResult<Self>
pub fn read(db: &mut Connection, item_id: i32) -> QueryResult<Self>
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
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
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
]
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>
sourcepub fn delete(db: &mut Connection, item_id: i32) -> QueryResult<usize>
pub fn delete(db: &mut Connection, item_id: i32) -> QueryResult<usize>
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
Trait Implementations§
source§impl<'update> AsChangeset for &'update UserSession
impl<'update> AsChangeset for &'update UserSession
§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::Changeset
fn as_changeset(self) -> Self::Changeset
Convert
self
into the actual update statement being executedsource§impl AsChangeset for UserSession
impl AsChangeset for UserSession
§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::Changeset
fn as_changeset(self) -> Self::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>,
§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
§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>,
§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
§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 copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
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 UserSessionwhere
(i32, i32, String, Option<String>, DateTime<Utc>, DateTime<Utc>): FromStaticSqlRow<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5), __DB>,
impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5), __DB> for UserSessionwhere (i32, i32, String, Option<String>, DateTime<Utc>, DateTime<Utc>): FromStaticSqlRow<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5), __DB>,
Auto Trait Implementations§
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]>,
§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> Self::Expressionwhere Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,
Convert
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,
Convert
&self
to an expression for Diesel’s query builder. Read moresource§impl<T, ST, DB> StaticallySizedRow<ST, DB> for Twhere
ST: SqlTypeOrSelectable + TupleSize,
T: Queryable<ST, DB>,
DB: Backend,
impl<T, ST, DB> StaticallySizedRow<ST, DB> for Twhere ST: SqlTypeOrSelectable + TupleSize, T: Queryable<ST, DB>, DB: Backend,
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.