-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: save workspace member info to disk
- Loading branch information
Showing
14 changed files
with
187 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
frontend/rust-lib/flowy-user/src/services/sqlite_sql/member_sql.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use diesel::{insert_into, RunQueryDsl}; | ||
use flowy_error::FlowyResult; | ||
|
||
use flowy_sqlite::schema::workspace_members_table; | ||
|
||
use flowy_sqlite::schema::workspace_members_table::dsl; | ||
use flowy_sqlite::{query_dsl::*, DBConnection, ExpressionMethods}; | ||
|
||
#[derive(Queryable, Insertable, AsChangeset, Debug)] | ||
#[diesel(table_name = workspace_members_table)] | ||
#[diesel(primary_key(email, workspace_id))] | ||
pub struct WorkspaceMemberTable { | ||
pub email: String, | ||
pub role: i32, | ||
pub name: String, | ||
pub avatar_url: Option<String>, | ||
pub uid: i64, | ||
pub workspace_id: String, | ||
pub updated_at: chrono::NaiveDateTime, | ||
} | ||
|
||
pub fn upsert_workspace_member<T: Into<WorkspaceMemberTable>>( | ||
mut conn: DBConnection, | ||
member: T, | ||
) -> FlowyResult<()> { | ||
let member = member.into(); | ||
|
||
insert_into(workspace_members_table::table) | ||
.values(&member) | ||
.on_conflict(( | ||
workspace_members_table::email, | ||
workspace_members_table::workspace_id, | ||
)) | ||
.do_update() | ||
.set(&member) | ||
.execute(&mut conn)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn select_workspace_member( | ||
mut conn: DBConnection, | ||
workspace_id: &str, | ||
uid: i64, | ||
) -> FlowyResult<WorkspaceMemberTable> { | ||
let member = dsl::workspace_members_table | ||
.filter(workspace_members_table::workspace_id.eq(workspace_id)) | ||
.filter(workspace_members_table::uid.eq(uid)) | ||
.first::<WorkspaceMemberTable>(&mut conn)?; | ||
|
||
Ok(member) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub(crate) mod member_sql; | ||
pub(crate) mod user_sql; | ||
pub(crate) mod workspace_sql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters