mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
enable sqlx offline
This commit is contained in:
parent
952ac1cd3c
commit
3f65d3eb48
@ -28,6 +28,7 @@ derive_more = {version = "0.99", features = ["display"]}
|
||||
protobuf = {version = "2.20.0"}
|
||||
uuid = { version = "0.8", features = ["serde", "v4"] }
|
||||
config = { version = "0.10.1", default-features = false, features = ["yaml"] }
|
||||
chrono = "0.4.19"
|
||||
|
||||
flowy-log = { path = "../rust-lib/flowy-log" }
|
||||
flowy-user = { path = "../rust-lib/flowy-user" }
|
||||
|
@ -8,7 +8,7 @@ WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
# Let's build our binary!
|
||||
# We'll use the release profile to make it faaaast
|
||||
# We'll use the release profile to make it fast
|
||||
WORKDIR /app/backend
|
||||
RUN cargo build --release
|
||||
# When `docker run` is executed, launch the binary!
|
||||
|
@ -13,8 +13,7 @@ bfcdd6369e89 postgres "docker-entrypoint.s…" 19 minutes ago Up 19 minu
|
||||
```
|
||||
|
||||
4. run `make init_database`. It will create the database on the remote specified by DATABASE_URL. You can connect you database using
|
||||
pgAdmin.
|
||||
|
||||
pgAdmin.
|
||||
|
||||

|
||||
|
||||
|
@ -10,7 +10,7 @@ init_docker:
|
||||
${ROOT}/docker.sh
|
||||
|
||||
init_database:
|
||||
${ROOT}/init.sh
|
||||
${ROOT}/db_init.sh
|
||||
|
||||
reset_db:
|
||||
sqlx database reset
|
||||
|
19
backend/sqlx-data.json
Normal file
19
backend/sqlx-data.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"db": "PostgreSQL",
|
||||
"e8c487b4314c267f6da2667b95f6c8003fabc2461c10df2d6d39d081e74e167f": {
|
||||
"query": "\n INSERT INTO user_table (id, email, name, create_time, password)\n VALUES ($1, $2, $3, $4, $5)\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Text",
|
||||
"Text",
|
||||
"Timestamptz",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ pub async fn register(
|
||||
auth: Data<Arc<Auth>>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let params: SignUpParams = parse_from_payload(payload).await?;
|
||||
let _ = auth.sign_up(params)?;
|
||||
let _ = auth.sign_up(params).await?;
|
||||
|
||||
let resp = FlowyResponse::success();
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use chrono::Utc;
|
||||
use flowy_net::response::{ServerCode, ServerError};
|
||||
use flowy_user::{entities::SignUpResponse, protobuf::SignUpParams};
|
||||
use sqlx::PgPool;
|
||||
@ -10,12 +11,29 @@ pub struct Auth {
|
||||
impl Auth {
|
||||
pub fn new(db_pool: Arc<PgPool>) -> Self { Self { db_pool } }
|
||||
|
||||
pub fn sign_up(&self, params: SignUpParams) -> Result<SignUpResponse, ServerError> {
|
||||
pub async fn sign_up(&self, params: SignUpParams) -> Result<SignUpResponse, ServerError> {
|
||||
// email exist?
|
||||
|
||||
// generate user id
|
||||
let result = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO user_table (id, email, name, create_time, password)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
"#,
|
||||
uuid::Uuid::new_v4(),
|
||||
params.email,
|
||||
params.name,
|
||||
Utc::now(),
|
||||
"123".to_string()
|
||||
)
|
||||
.execute(self.db_pool.as_ref())
|
||||
.await;
|
||||
|
||||
unimplemented!()
|
||||
let response = SignUpResponse {
|
||||
uid: "".to_string(),
|
||||
name: "".to_string(),
|
||||
email: "".to_string(),
|
||||
};
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
pub fn is_email_exist(&self, email: &str) -> bool { true }
|
||||
|
Loading…
Reference in New Issue
Block a user