Bump: 0.5.0 : unlisted, password and locked stream support
This commit is contained in:
@@ -12,6 +12,8 @@ pub struct Model {
|
||||
pub label: String,
|
||||
pub is_active: bool,
|
||||
pub is_unlisted: bool,
|
||||
pub password: Option<String>,
|
||||
pub custom_id: Option<String>,
|
||||
pub created_at: DateTimeUtc,
|
||||
}
|
||||
|
||||
@@ -78,6 +80,16 @@ impl Entity {
|
||||
.all(db)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn find_by_custom_id(
|
||||
db: &DatabaseConnection,
|
||||
custom_id: String,
|
||||
) -> Result<Option<Model>, DbErr> {
|
||||
Entity::find()
|
||||
.filter(Column::CustomId.eq(custom_id))
|
||||
.one(db)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModel {
|
||||
@@ -89,4 +101,17 @@ impl ActiveModel {
|
||||
self.label = Set(value);
|
||||
self.update(db).await
|
||||
}
|
||||
|
||||
pub async fn password(
|
||||
mut self,
|
||||
db: &DatabaseConnection,
|
||||
value: String,
|
||||
) -> Result<Model, DbErr> {
|
||||
self.password = if value.is_empty() {
|
||||
Set(None)
|
||||
} else {
|
||||
Set(Some(value))
|
||||
};
|
||||
self.update(db).await
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user