create op table

This commit is contained in:
appflowy
2021-09-23 13:15:35 +08:00
parent 2b9bc7a0cd
commit 302631f808
39 changed files with 528 additions and 405 deletions

View File

@ -4,7 +4,7 @@ use crate::{
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
};
use anyhow::Context;
use flowy_document::protobuf::{CreateDocParams, Doc, QueryDocParams, SaveDocParams};
use flowy_document::protobuf::{CreateDocParams, Doc, QueryDocParams, UpdateDocParams};
use flowy_net::{errors::ServerError, response::FlowyResponse};
use sqlx::{postgres::PgArguments, PgPool, Postgres};
use uuid::Uuid;
@ -55,9 +55,9 @@ pub(crate) async fn read_doc(
pub(crate) async fn update_doc(
pool: &PgPool,
mut params: SaveDocParams,
mut params: UpdateDocParams,
) -> Result<FlowyResponse, ServerError> {
let doc_id = Uuid::parse_str(&params.id)?;
let doc_id = Uuid::parse_str(&params.doc_id)?;
let mut transaction = pool
.begin()
.await

View File

@ -4,7 +4,7 @@ use actix_web::{
};
use sqlx::PgPool;
use flowy_document::protobuf::{QueryDocParams, SaveDocParams};
use flowy_document::protobuf::{QueryDocParams, UpdateDocParams};
use flowy_net::errors::ServerError;
use crate::service::{
@ -25,7 +25,7 @@ pub async fn update_handler(
payload: Payload,
pool: Data<PgPool>,
) -> Result<HttpResponse, ServerError> {
let params: SaveDocParams = parse_from_payload(payload).await?;
let params: UpdateDocParams = parse_from_payload(payload).await?;
let response = update_doc(pool.get_ref(), params).await?;
Ok(response.into())
}