mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: migrate flowy-database (#2373)
* feat: add flowy-database2 * chore: config type option data * chore: impl type option * feat: config group * fix: group compile * feat: add sort * chore: setting * chore: insert with specific type * chore: custom group * chore: rename any map * chore: use group setting * chore: update * chore: open database event * chore: update database editor * chore: update * chore: update view editor * chore: update * chore: update view editor * chore: sort feat * chore: update handler * chore: update * chore: config handler event * feat: impl handlers * feat: impl handlers * chore: layout setting * feat: impl handlers * chore: remove flowy-folder ref * chore: integrate flowy-database2 * feat: get cell * chore: create database with data * chore: create view * chore: fix dart compile * fix: some bugs * chore: update * chore: merge develop * chore: fix warning * chore: integrate rocksdb * fix: rocksdb compile errros * fix: update cell * chore: update the bundle identifier * fix: create row * fix: switch to field * fix: duplicate grid * test: migrate tests * test: migrate tests * test: update test * test: migrate tests * chore: add patch
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
use std::path::PathBuf;
|
||||
use std::{collections::HashMap, sync::Arc, time::Duration};
|
||||
|
||||
use collab_persistence::kv::rocks_kv::RocksCollabDB;
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_sqlite::ConnectionPool;
|
||||
use flowy_sqlite::{schema::user_table, DBConnection, Database};
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
use std::path::PathBuf;
|
||||
use std::{collections::HashMap, sync::Arc, time::Duration};
|
||||
use user_model::{SignInResponse, SignUpResponse, UpdateUserProfileParams, UserProfile};
|
||||
|
||||
pub struct UserDB {
|
||||
@ -65,10 +67,10 @@ impl UserDB {
|
||||
|
||||
tracing::trace!("open kv db {} at path: {:?}", user_id, dir);
|
||||
let db = RocksCollabDB::open(dir).map_err(|err| FlowyError::internal().context(err))?;
|
||||
let kv_db = Arc::new(db);
|
||||
write_guard.insert(user_id.to_owned(), kv_db.clone());
|
||||
let db = Arc::new(db);
|
||||
write_guard.insert(user_id.to_owned(), db.clone());
|
||||
drop(write_guard);
|
||||
Ok(kv_db)
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
pub(crate) fn close_user_db(&self, user_id: i64) -> Result<(), FlowyError> {
|
||||
@ -133,19 +135,19 @@ impl UserTable {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<SignUpResponse> for UserTable {
|
||||
impl From<SignUpResponse> for UserTable {
|
||||
fn from(resp: SignUpResponse) -> Self {
|
||||
UserTable::new(resp.user_id.to_string(), resp.name, resp.email, resp.token)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<SignInResponse> for UserTable {
|
||||
impl From<SignInResponse> for UserTable {
|
||||
fn from(resp: SignInResponse) -> Self {
|
||||
UserTable::new(resp.user_id.to_string(), resp.name, resp.email, resp.token)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<UserTable> for UserProfile {
|
||||
impl From<UserTable> for UserProfile {
|
||||
fn from(table: UserTable) -> Self {
|
||||
UserProfile {
|
||||
id: table.id.parse::<i64>().unwrap_or(0),
|
||||
|
@ -1,12 +1,5 @@
|
||||
use crate::entities::{UserProfilePB, UserSettingPB};
|
||||
use crate::event_map::UserStatusCallback;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
errors::{ErrorCode, FlowyError},
|
||||
event_map::UserCloudService,
|
||||
notification::*,
|
||||
services::database::{UserDB, UserTable, UserTableChangeset},
|
||||
};
|
||||
use collab_persistence::kv::rocks_kv::RocksCollabDB;
|
||||
use flowy_sqlite::ConnectionPool;
|
||||
use flowy_sqlite::{
|
||||
@ -15,14 +8,21 @@ use flowy_sqlite::{
|
||||
schema::{user_table, user_table::dsl},
|
||||
DBConnection, ExpressionMethods, UserDatabaseConnection,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use user_model::{
|
||||
SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfile,
|
||||
};
|
||||
|
||||
use crate::entities::{UserProfilePB, UserSettingPB};
|
||||
use crate::event_map::UserStatusCallback;
|
||||
use crate::{
|
||||
errors::{ErrorCode, FlowyError},
|
||||
event_map::UserCloudService,
|
||||
notification::*,
|
||||
services::database::{UserDB, UserTable, UserTableChangeset},
|
||||
};
|
||||
|
||||
// lazy_static! {
|
||||
// static ref ID_GEN: Mutex<UserIDGenerator> = Mutex::new(UserIDGenerator::new(1));
|
||||
// }
|
||||
|
Reference in New Issue
Block a user