config doc sql table

This commit is contained in:
appflowy 2021-07-23 08:14:45 +08:00
parent 2bb332fb2c
commit 4e80b296f8
35 changed files with 904 additions and 129 deletions

View File

@ -11,23 +11,28 @@ import 'package:protobuf/protobuf.dart' as $pb;
class CreateDocRequest extends $pb.GeneratedMessage { class CreateDocRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CreateDocRequest', createEmptyInstance: create) static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CreateDocRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewId') ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc')
..hasRequiredFields = false ..hasRequiredFields = false
; ;
CreateDocRequest._() : super(); CreateDocRequest._() : super();
factory CreateDocRequest({ factory CreateDocRequest({
$core.String? viewId, $core.String? id,
$core.String? name, $core.String? name,
$core.String? desc,
}) { }) {
final _result = create(); final _result = create();
if (viewId != null) { if (id != null) {
_result.viewId = viewId; _result.id = id;
} }
if (name != null) { if (name != null) {
_result.name = name; _result.name = name;
} }
if (desc != null) {
_result.desc = desc;
}
return _result; return _result;
} }
factory CreateDocRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory CreateDocRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
@ -52,13 +57,13 @@ class CreateDocRequest extends $pb.GeneratedMessage {
static CreateDocRequest? _defaultInstance; static CreateDocRequest? _defaultInstance;
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.String get viewId => $_getSZ(0); $core.String get id => $_getSZ(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
set viewId($core.String v) { $_setString(0, v); } set id($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.bool hasViewId() => $_has(0); $core.bool hasId() => $_has(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
void clearViewId() => clearField(1); void clearId() => clearField(1);
@$pb.TagNumber(2) @$pb.TagNumber(2)
$core.String get name => $_getSZ(1); $core.String get name => $_getSZ(1);
@ -68,13 +73,24 @@ class CreateDocRequest extends $pb.GeneratedMessage {
$core.bool hasName() => $_has(1); $core.bool hasName() => $_has(1);
@$pb.TagNumber(2) @$pb.TagNumber(2)
void clearName() => clearField(2); void clearName() => clearField(2);
@$pb.TagNumber(3)
$core.String get desc => $_getSZ(2);
@$pb.TagNumber(3)
set desc($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasDesc() => $_has(2);
@$pb.TagNumber(3)
void clearDesc() => clearField(3);
} }
class Doc extends $pb.GeneratedMessage { class Doc extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Doc', createEmptyInstance: create) static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Doc', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id') ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'viewId') ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc')
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'path')
..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'content')
..hasRequiredFields = false ..hasRequiredFields = false
; ;
@ -82,7 +98,9 @@ class Doc extends $pb.GeneratedMessage {
factory Doc({ factory Doc({
$core.String? id, $core.String? id,
$core.String? name, $core.String? name,
$core.String? viewId, $core.String? desc,
$core.String? path,
$core.String? content,
}) { }) {
final _result = create(); final _result = create();
if (id != null) { if (id != null) {
@ -91,8 +109,14 @@ class Doc extends $pb.GeneratedMessage {
if (name != null) { if (name != null) {
_result.name = name; _result.name = name;
} }
if (viewId != null) { if (desc != null) {
_result.viewId = viewId; _result.desc = desc;
}
if (path != null) {
_result.path = path;
}
if (content != null) {
_result.content = content;
} }
return _result; return _result;
} }
@ -136,12 +160,30 @@ class Doc extends $pb.GeneratedMessage {
void clearName() => clearField(2); void clearName() => clearField(2);
@$pb.TagNumber(3) @$pb.TagNumber(3)
$core.String get viewId => $_getSZ(2); $core.String get desc => $_getSZ(2);
@$pb.TagNumber(3) @$pb.TagNumber(3)
set viewId($core.String v) { $_setString(2, v); } set desc($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3) @$pb.TagNumber(3)
$core.bool hasViewId() => $_has(2); $core.bool hasDesc() => $_has(2);
@$pb.TagNumber(3) @$pb.TagNumber(3)
void clearViewId() => clearField(3); void clearDesc() => clearField(3);
@$pb.TagNumber(4)
$core.String get path => $_getSZ(3);
@$pb.TagNumber(4)
set path($core.String v) { $_setString(3, v); }
@$pb.TagNumber(4)
$core.bool hasPath() => $_has(3);
@$pb.TagNumber(4)
void clearPath() => clearField(4);
@$pb.TagNumber(5)
$core.String get content => $_getSZ(4);
@$pb.TagNumber(5)
set content($core.String v) { $_setString(4, v); }
@$pb.TagNumber(5)
$core.bool hasContent() => $_has(4);
@$pb.TagNumber(5)
void clearContent() => clearField(5);
} }

View File

@ -12,22 +12,25 @@ import 'dart:typed_data' as $typed_data;
const CreateDocRequest$json = const { const CreateDocRequest$json = const {
'1': 'CreateDocRequest', '1': 'CreateDocRequest',
'2': const [ '2': const [
const {'1': 'view_id', '3': 1, '4': 1, '5': 9, '10': 'viewId'}, const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'desc', '3': 3, '4': 1, '5': 9, '10': 'desc'},
], ],
}; };
/// Descriptor for `CreateDocRequest`. Decode as a `google.protobuf.DescriptorProto`. /// Descriptor for `CreateDocRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List createDocRequestDescriptor = $convert.base64Decode('ChBDcmVhdGVEb2NSZXF1ZXN0EhcKB3ZpZXdfaWQYASABKAlSBnZpZXdJZBISCgRuYW1lGAIgASgJUgRuYW1l'); final $typed_data.Uint8List createDocRequestDescriptor = $convert.base64Decode('ChBDcmVhdGVEb2NSZXF1ZXN0Eg4KAmlkGAEgASgJUgJpZBISCgRuYW1lGAIgASgJUgRuYW1lEhIKBGRlc2MYAyABKAlSBGRlc2M=');
@$core.Deprecated('Use docDescriptor instead') @$core.Deprecated('Use docDescriptor instead')
const Doc$json = const { const Doc$json = const {
'1': 'Doc', '1': 'Doc',
'2': const [ '2': const [
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'view_id', '3': 3, '4': 1, '5': 9, '10': 'viewId'}, const {'1': 'desc', '3': 3, '4': 1, '5': 9, '10': 'desc'},
const {'1': 'path', '3': 4, '4': 1, '5': 9, '10': 'path'},
const {'1': 'content', '3': 5, '4': 1, '5': 9, '10': 'content'},
], ],
}; };
/// Descriptor for `Doc`. Decode as a `google.protobuf.DescriptorProto`. /// Descriptor for `Doc`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List docDescriptor = $convert.base64Decode('CgNEb2MSDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSFwoHdmlld19pZBgDIAEoCVIGdmlld0lk'); final $typed_data.Uint8List docDescriptor = $convert.base64Decode('CgNEb2MSDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbWUSEgoEZGVzYxgDIAEoCVIEZGVzYxISCgRwYXRoGAQgASgJUgRwYXRoEhgKB2NvbnRlbnQYBSABKAlSB2NvbnRlbnQ=');

View File

@ -0,0 +1,72 @@
///
// Generated code. Do not modify.
// source: doc_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class QueryDocRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'QueryDocRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId')
..aOB(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'readContent')
..hasRequiredFields = false
;
QueryDocRequest._() : super();
factory QueryDocRequest({
$core.String? docId,
$core.bool? readContent,
}) {
final _result = create();
if (docId != null) {
_result.docId = docId;
}
if (readContent != null) {
_result.readContent = readContent;
}
return _result;
}
factory QueryDocRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory QueryDocRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
QueryDocRequest clone() => QueryDocRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
QueryDocRequest copyWith(void Function(QueryDocRequest) updates) => super.copyWith((message) => updates(message as QueryDocRequest)) as QueryDocRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static QueryDocRequest create() => QueryDocRequest._();
QueryDocRequest createEmptyInstance() => create();
static $pb.PbList<QueryDocRequest> createRepeated() => $pb.PbList<QueryDocRequest>();
@$core.pragma('dart2js:noInline')
static QueryDocRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<QueryDocRequest>(create);
static QueryDocRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get docId => $_getSZ(0);
@$pb.TagNumber(1)
set docId($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasDocId() => $_has(0);
@$pb.TagNumber(1)
void clearDocId() => clearField(1);
@$pb.TagNumber(2)
$core.bool get readContent => $_getBF(1);
@$pb.TagNumber(2)
set readContent($core.bool v) { $_setBool(1, v); }
@$pb.TagNumber(2)
$core.bool hasReadContent() => $_has(1);
@$pb.TagNumber(2)
void clearReadContent() => clearField(2);
}

View File

@ -0,0 +1,7 @@
///
// Generated code. Do not modify.
// source: doc_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields

View File

@ -0,0 +1,21 @@
///
// Generated code. Do not modify.
// source: doc_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use queryDocRequestDescriptor instead')
const QueryDocRequest$json = const {
'1': 'QueryDocRequest',
'2': const [
const {'1': 'doc_id', '3': 1, '4': 1, '5': 9, '10': 'docId'},
const {'1': 'read_content', '3': 2, '4': 1, '5': 8, '10': 'readContent'},
],
};
/// Descriptor for `QueryDocRequest`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List queryDocRequestDescriptor = $convert.base64Decode('Cg9RdWVyeURvY1JlcXVlc3QSFQoGZG9jX2lkGAEgASgJUgVkb2NJZBIhCgxyZWFkX2NvbnRlbnQYAiABKAhSC3JlYWRDb250ZW50');

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: doc_query.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'doc_query.pb.dart';

View File

@ -2,3 +2,4 @@
export './doc_create.pb.dart'; export './doc_create.pb.dart';
export './errors.pb.dart'; export './errors.pb.dart';
export './event.pb.dart'; export './event.pb.dart';
export './doc_query.pb.dart';

View File

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE doc_table;

View File

@ -0,0 +1,10 @@
-- Your SQL goes here
CREATE TABLE doc_table (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
path TEXT NOT NULL DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
version BIGINT NOT NULL DEFAULT 0
);

View File

@ -12,6 +12,18 @@ table! {
} }
} }
table! {
doc_table (id) {
id -> Text,
name -> Text,
desc -> Text,
path -> Text,
modified_time -> BigInt,
create_time -> BigInt,
version -> BigInt,
}
}
table! { table! {
user_table (id) { user_table (id) {
id -> Text, id -> Text,
@ -50,6 +62,7 @@ table! {
allow_tables_to_appear_in_same_query!( allow_tables_to_appear_in_same_query!(
app_table, app_table,
doc_table,
user_table, user_table,
view_table, view_table,
workspace_table, workspace_table,

View File

@ -19,6 +19,7 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "KeyValue" | "KeyValue"
| "CreateDocRequest" | "CreateDocRequest"
| "Doc" | "Doc"
| "QueryDocRequest"
| "EditorError" | "EditorError"
| "QueryAppRequest" | "QueryAppRequest"
| "CreateAppRequest" | "CreateAppRequest"

View File

@ -11,6 +11,10 @@ flowy-dispatch = { path = "../flowy-dispatch" }
flowy-log = { path = "../flowy-log" } flowy-log = { path = "../flowy-log" }
flowy-derive = { path = "../flowy-derive" } flowy-derive = { path = "../flowy-derive" }
flowy-database = { path = "../flowy-database" } flowy-database = { path = "../flowy-database" }
flowy-infra = { path = "../flowy-infra" }
diesel = {version = "1.4.7", features = ["sqlite"]} diesel = {version = "1.4.7", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]} diesel_derives = {version = "1.4.1", features = ["sqlite"]}
protobuf = {version = "2.18.0"} protobuf = {version = "2.18.0"}
[dev-dependencies]
flowy-test = { path = "../flowy-test" }

View File

@ -8,15 +8,19 @@ use std::convert::TryInto;
#[derive(ProtoBuf, Default)] #[derive(ProtoBuf, Default)]
pub struct CreateDocRequest { pub struct CreateDocRequest {
#[pb(index = 1)] #[pb(index = 1)]
view_id: String, id: String,
#[pb(index = 2)] #[pb(index = 2)]
pub name: String, pub name: String,
#[pb(index = 3)]
pub desc: String,
} }
pub struct CreateDocParams { pub struct CreateDocParams {
pub view_id: String, pub id: String,
pub name: String, pub name: String,
pub desc: String,
} }
impl TryInto<CreateDocParams> for CreateDocRequest { impl TryInto<CreateDocParams> for CreateDocRequest {
@ -31,7 +35,7 @@ impl TryInto<CreateDocParams> for CreateDocRequest {
})? })?
.0; .0;
let view_id = DocViewId::parse(self.view_id) let id = DocViewId::parse(self.id)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid) ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid)
.msg(e) .msg(e)
@ -39,7 +43,11 @@ impl TryInto<CreateDocParams> for CreateDocRequest {
})? })?
.0; .0;
Ok(CreateDocParams { view_id, name }) Ok(CreateDocParams {
id,
name,
desc: self.desc,
})
} }
} }
@ -52,5 +60,11 @@ pub struct Doc {
pub name: String, pub name: String,
#[pb(index = 3)] #[pb(index = 3)]
pub view_id: String, pub desc: String,
#[pb(index = 4)]
pub path: String,
#[pb(index = 5)]
pub content: String,
} }

View File

@ -0,0 +1,5 @@
pub(crate) struct UpdateDocParams {
pub(crate) id: String,
pub(crate) name: Option<String>,
pub(crate) desc: Option<String>,
}

View File

@ -0,0 +1,36 @@
use crate::{entities::doc::parser::DocId, errors::*};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(Default, ProtoBuf)]
pub struct QueryDocRequest {
#[pb(index = 1)]
pub doc_id: String,
#[pb(index = 2)]
pub read_content: bool,
}
pub struct QueryDocParams {
pub doc_id: String,
pub read_content: bool,
}
impl TryInto<QueryDocParams> for QueryDocRequest {
type Error = EditorError;
fn try_into(self) -> Result<QueryDocParams, Self::Error> {
let doc_id = DocId::parse(self.doc_id)
.map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid)
.msg(e)
.build()
})?
.0;
Ok(QueryDocParams {
doc_id,
read_content: self.read_content,
})
}
}

View File

@ -1,5 +1,8 @@
mod doc_create; mod doc_create;
mod doc_modify; mod doc_modify;
mod doc_query;
mod parser; mod parser;
pub use doc_create::*; pub use doc_create::*;
pub use doc_modify::*;
pub use doc_query::*;

View File

@ -0,0 +1,12 @@
#[derive(Debug)]
pub struct DocId(pub String);
impl DocId {
pub fn parse(s: String) -> Result<DocId, String> {
if s.trim().is_empty() {
return Err(format!("Doc id can not be empty or whitespace"));
}
Ok(Self(s))
}
}

View File

@ -1,5 +1,7 @@
mod doc_id;
mod doc_name; mod doc_name;
mod doc_view_id; mod doc_view_id;
pub use doc_id::*;
pub use doc_name::*; pub use doc_name::*;
pub use doc_view_id::*; pub use doc_view_id::*;

View File

@ -1,12 +1,15 @@
use crate::{entities::doc::*, errors::EditorError}; use crate::{entities::doc::*, errors::EditorError, services::file_manager::FileManager};
use flowy_dispatch::prelude::*; use flowy_dispatch::prelude::*;
use std::{convert::TryInto, sync::Arc}; use std::{
convert::TryInto,
sync::{Arc, RwLock},
};
pub async fn create_doc( pub async fn create_doc(
data: Data<CreateDocRequest>, data: Data<CreateDocRequest>,
// session: ModuleData<Arc<UserSession>>, manager: ModuleData<RwLock<FileManager>>,
) -> ResponseResult<Doc, EditorError> { ) -> ResponseResult<Doc, EditorError> {
// let params: SignInParams = data.into_inner().try_into()?; let params: CreateDocParams = data.into_inner().try_into()?;
// let user = session.sign_in(params).await?; // let user = session.sign_in(params).await?;
// let user_detail = UserDetail::from(user); // let user_detail = UserDetail::from(user);
// response_ok(user_detail) // response_ok(user_detail)

View File

@ -5,6 +5,10 @@ mod handlers;
pub mod module; pub mod module;
mod protobuf; mod protobuf;
mod services; mod services;
mod sql_tables;
#[macro_use]
extern crate flowy_database;
pub mod prelude { pub mod prelude {
pub use crate::module::*; pub use crate::module::*;

View File

@ -1,7 +1,17 @@
use crate::{event::EditorEvent, handlers::*, services::file_manager::FileManager}; use crate::{
errors::EditorError,
event::EditorEvent,
handlers::*,
services::file_manager::FileManager,
};
use flowy_database::DBConnection;
use flowy_dispatch::prelude::*; use flowy_dispatch::prelude::*;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
pub trait EditorDatabase: Send + Sync {
fn db_connection(&self) -> Result<DBConnection, EditorError>;
}
pub fn create() -> Module { pub fn create() -> Module {
let file_manager = RwLock::new(FileManager::new()); let file_manager = RwLock::new(FileManager::new());

View File

@ -26,8 +26,9 @@
#[derive(PartialEq,Clone,Default)] #[derive(PartialEq,Clone,Default)]
pub struct CreateDocRequest { pub struct CreateDocRequest {
// message fields // message fields
pub view_id: ::std::string::String, pub id: ::std::string::String,
pub name: ::std::string::String, pub name: ::std::string::String,
pub desc: ::std::string::String,
// special fields // special fields
pub unknown_fields: ::protobuf::UnknownFields, pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize, pub cached_size: ::protobuf::CachedSize,
@ -44,30 +45,30 @@ impl CreateDocRequest {
::std::default::Default::default() ::std::default::Default::default()
} }
// string view_id = 1; // string id = 1;
pub fn get_view_id(&self) -> &str { pub fn get_id(&self) -> &str {
&self.view_id &self.id
} }
pub fn clear_view_id(&mut self) { pub fn clear_id(&mut self) {
self.view_id.clear(); self.id.clear();
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_view_id(&mut self, v: ::std::string::String) { pub fn set_id(&mut self, v: ::std::string::String) {
self.view_id = v; self.id = v;
} }
// Mutable pointer to the field. // Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first. // If field is not initialized, it is initialized with default value first.
pub fn mut_view_id(&mut self) -> &mut ::std::string::String { pub fn mut_id(&mut self) -> &mut ::std::string::String {
&mut self.view_id &mut self.id
} }
// Take field // Take field
pub fn take_view_id(&mut self) -> ::std::string::String { pub fn take_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.view_id, ::std::string::String::new()) ::std::mem::replace(&mut self.id, ::std::string::String::new())
} }
// string name = 2; // string name = 2;
@ -95,6 +96,32 @@ impl CreateDocRequest {
pub fn take_name(&mut self) -> ::std::string::String { pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new()) ::std::mem::replace(&mut self.name, ::std::string::String::new())
} }
// string desc = 3;
pub fn get_desc(&self) -> &str {
&self.desc
}
pub fn clear_desc(&mut self) {
self.desc.clear();
}
// Param is passed by value, moved
pub fn set_desc(&mut self, v: ::std::string::String) {
self.desc = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_desc(&mut self) -> &mut ::std::string::String {
&mut self.desc
}
// Take field
pub fn take_desc(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.desc, ::std::string::String::new())
}
} }
impl ::protobuf::Message for CreateDocRequest { impl ::protobuf::Message for CreateDocRequest {
@ -107,11 +134,14 @@ impl ::protobuf::Message for CreateDocRequest {
let (field_number, wire_type) = is.read_tag_unpack()?; let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number { match field_number {
1 => { 1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.view_id)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?;
}, },
2 => { 2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
}, },
3 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?;
},
_ => { _ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
}, },
@ -124,24 +154,30 @@ impl ::protobuf::Message for CreateDocRequest {
#[allow(unused_variables)] #[allow(unused_variables)]
fn compute_size(&self) -> u32 { fn compute_size(&self) -> u32 {
let mut my_size = 0; let mut my_size = 0;
if !self.view_id.is_empty() { if !self.id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.view_id); my_size += ::protobuf::rt::string_size(1, &self.id);
} }
if !self.name.is_empty() { if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.name); my_size += ::protobuf::rt::string_size(2, &self.name);
} }
if !self.desc.is_empty() {
my_size += ::protobuf::rt::string_size(3, &self.desc);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size); self.cached_size.set(my_size);
my_size my_size
} }
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.view_id.is_empty() { if !self.id.is_empty() {
os.write_string(1, &self.view_id)?; os.write_string(1, &self.id)?;
} }
if !self.name.is_empty() { if !self.name.is_empty() {
os.write_string(2, &self.name)?; os.write_string(2, &self.name)?;
} }
if !self.desc.is_empty() {
os.write_string(3, &self.desc)?;
}
os.write_unknown_fields(self.get_unknown_fields())?; os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(()) ::std::result::Result::Ok(())
} }
@ -181,15 +217,20 @@ impl ::protobuf::Message for CreateDocRequest {
descriptor.get(|| { descriptor.get(|| {
let mut fields = ::std::vec::Vec::new(); let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"view_id", "id",
|m: &CreateDocRequest| { &m.view_id }, |m: &CreateDocRequest| { &m.id },
|m: &mut CreateDocRequest| { &mut m.view_id }, |m: &mut CreateDocRequest| { &mut m.id },
)); ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name", "name",
|m: &CreateDocRequest| { &m.name }, |m: &CreateDocRequest| { &m.name },
|m: &mut CreateDocRequest| { &mut m.name }, |m: &mut CreateDocRequest| { &mut m.name },
)); ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"desc",
|m: &CreateDocRequest| { &m.desc },
|m: &mut CreateDocRequest| { &mut m.desc },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<CreateDocRequest>( ::protobuf::reflect::MessageDescriptor::new_pb_name::<CreateDocRequest>(
"CreateDocRequest", "CreateDocRequest",
fields, fields,
@ -206,8 +247,9 @@ impl ::protobuf::Message for CreateDocRequest {
impl ::protobuf::Clear for CreateDocRequest { impl ::protobuf::Clear for CreateDocRequest {
fn clear(&mut self) { fn clear(&mut self) {
self.view_id.clear(); self.id.clear();
self.name.clear(); self.name.clear();
self.desc.clear();
self.unknown_fields.clear(); self.unknown_fields.clear();
} }
} }
@ -229,7 +271,9 @@ pub struct Doc {
// message fields // message fields
pub id: ::std::string::String, pub id: ::std::string::String,
pub name: ::std::string::String, pub name: ::std::string::String,
pub view_id: ::std::string::String, pub desc: ::std::string::String,
pub path: ::std::string::String,
pub content: ::std::string::String,
// special fields // special fields
pub unknown_fields: ::protobuf::UnknownFields, pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize, pub cached_size: ::protobuf::CachedSize,
@ -298,30 +342,82 @@ impl Doc {
::std::mem::replace(&mut self.name, ::std::string::String::new()) ::std::mem::replace(&mut self.name, ::std::string::String::new())
} }
// string view_id = 3; // string desc = 3;
pub fn get_view_id(&self) -> &str { pub fn get_desc(&self) -> &str {
&self.view_id &self.desc
} }
pub fn clear_view_id(&mut self) { pub fn clear_desc(&mut self) {
self.view_id.clear(); self.desc.clear();
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_view_id(&mut self, v: ::std::string::String) { pub fn set_desc(&mut self, v: ::std::string::String) {
self.view_id = v; self.desc = v;
} }
// Mutable pointer to the field. // Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first. // If field is not initialized, it is initialized with default value first.
pub fn mut_view_id(&mut self) -> &mut ::std::string::String { pub fn mut_desc(&mut self) -> &mut ::std::string::String {
&mut self.view_id &mut self.desc
} }
// Take field // Take field
pub fn take_view_id(&mut self) -> ::std::string::String { pub fn take_desc(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.view_id, ::std::string::String::new()) ::std::mem::replace(&mut self.desc, ::std::string::String::new())
}
// string path = 4;
pub fn get_path(&self) -> &str {
&self.path
}
pub fn clear_path(&mut self) {
self.path.clear();
}
// Param is passed by value, moved
pub fn set_path(&mut self, v: ::std::string::String) {
self.path = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_path(&mut self) -> &mut ::std::string::String {
&mut self.path
}
// Take field
pub fn take_path(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.path, ::std::string::String::new())
}
// string content = 5;
pub fn get_content(&self) -> &str {
&self.content
}
pub fn clear_content(&mut self) {
self.content.clear();
}
// Param is passed by value, moved
pub fn set_content(&mut self, v: ::std::string::String) {
self.content = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_content(&mut self) -> &mut ::std::string::String {
&mut self.content
}
// Take field
pub fn take_content(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.content, ::std::string::String::new())
} }
} }
@ -341,7 +437,13 @@ impl ::protobuf::Message for Doc {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
}, },
3 => { 3 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.view_id)?; ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?;
},
4 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.path)?;
},
5 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.content)?;
}, },
_ => { _ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
@ -361,8 +463,14 @@ impl ::protobuf::Message for Doc {
if !self.name.is_empty() { if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.name); my_size += ::protobuf::rt::string_size(2, &self.name);
} }
if !self.view_id.is_empty() { if !self.desc.is_empty() {
my_size += ::protobuf::rt::string_size(3, &self.view_id); my_size += ::protobuf::rt::string_size(3, &self.desc);
}
if !self.path.is_empty() {
my_size += ::protobuf::rt::string_size(4, &self.path);
}
if !self.content.is_empty() {
my_size += ::protobuf::rt::string_size(5, &self.content);
} }
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size); self.cached_size.set(my_size);
@ -376,8 +484,14 @@ impl ::protobuf::Message for Doc {
if !self.name.is_empty() { if !self.name.is_empty() {
os.write_string(2, &self.name)?; os.write_string(2, &self.name)?;
} }
if !self.view_id.is_empty() { if !self.desc.is_empty() {
os.write_string(3, &self.view_id)?; os.write_string(3, &self.desc)?;
}
if !self.path.is_empty() {
os.write_string(4, &self.path)?;
}
if !self.content.is_empty() {
os.write_string(5, &self.content)?;
} }
os.write_unknown_fields(self.get_unknown_fields())?; os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(()) ::std::result::Result::Ok(())
@ -428,9 +542,19 @@ impl ::protobuf::Message for Doc {
|m: &mut Doc| { &mut m.name }, |m: &mut Doc| { &mut m.name },
)); ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"view_id", "desc",
|m: &Doc| { &m.view_id }, |m: &Doc| { &m.desc },
|m: &mut Doc| { &mut m.view_id }, |m: &mut Doc| { &mut m.desc },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"path",
|m: &Doc| { &m.path },
|m: &mut Doc| { &mut m.path },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"content",
|m: &Doc| { &m.content },
|m: &mut Doc| { &mut m.content },
)); ));
::protobuf::reflect::MessageDescriptor::new_pb_name::<Doc>( ::protobuf::reflect::MessageDescriptor::new_pb_name::<Doc>(
"Doc", "Doc",
@ -450,7 +574,9 @@ impl ::protobuf::Clear for Doc {
fn clear(&mut self) { fn clear(&mut self) {
self.id.clear(); self.id.clear();
self.name.clear(); self.name.clear();
self.view_id.clear(); self.desc.clear();
self.path.clear();
self.content.clear();
self.unknown_fields.clear(); self.unknown_fields.clear();
} }
} }
@ -468,27 +594,38 @@ impl ::protobuf::reflect::ProtobufValue for Doc {
} }
static file_descriptor_proto_data: &'static [u8] = b"\ static file_descriptor_proto_data: &'static [u8] = b"\
\n\x10doc_create.proto\"?\n\x10CreateDocRequest\x12\x17\n\x07view_id\x18\ \n\x10doc_create.proto\"J\n\x10CreateDocRequest\x12\x0e\n\x02id\x18\x01\
\x01\x20\x01(\tR\x06viewId\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\ \x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\x12\
\"B\n\x03Doc\x12\x0e\n\x02id\x18\x01\x20\x01(\tR\x02id\x12\x12\n\x04name\ \n\x04desc\x18\x03\x20\x01(\tR\x04desc\"k\n\x03Doc\x12\x0e\n\x02id\x18\
\x18\x02\x20\x01(\tR\x04name\x12\x17\n\x07view_id\x18\x03\x20\x01(\tR\ \x01\x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\
\x06viewIdJ\xd5\x02\n\x06\x12\x04\0\0\n\x01\n\x08\n\x01\x0c\x12\x03\0\0\ \x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12\x12\n\x04path\x18\x04\x20\
\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\ \x01(\tR\x04path\x12\x18\n\x07content\x18\x05\x20\x01(\tR\x07contentJ\
\x02\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x17\n\x0c\n\x05\x04\ \xfa\x03\n\x06\x12\x04\0\0\r\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\
\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\ \x02\x04\0\x12\x04\x02\0\x06\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x18\
\x0b\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x15\x16\n\x0b\n\x04\x04\ \n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x12\n\x0c\n\x05\x04\0\x02\0\x05\
\0\x02\x01\x12\x03\x04\x04\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\ \x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x0b\r\n\x0c\n\
\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0f\n\x0c\n\x05\x04\ \x05\x04\0\x02\0\x03\x12\x03\x03\x10\x11\n\x0b\n\x04\x04\0\x02\x01\x12\
\0\x02\x01\x03\x12\x03\x04\x12\x13\n\n\n\x02\x04\x01\x12\x04\x06\0\n\x01\ \x03\x04\x04\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\
\n\n\n\x03\x04\x01\x01\x12\x03\x06\x08\x0b\n\x0b\n\x04\x04\x01\x02\0\x12\ \x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0f\n\x0c\n\x05\x04\0\x02\x01\x03\
\x03\x07\x04\x12\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x07\x04\n\n\x0c\n\ \x12\x03\x04\x12\x13\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\x04\x14\n\x0c\
\x05\x04\x01\x02\0\x01\x12\x03\x07\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\ \n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\0\x02\x02\x01\
\x12\x03\x07\x10\x11\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x08\x04\x14\n\ \x12\x03\x05\x0b\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13\n\
\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\ \n\n\x02\x04\x01\x12\x04\x07\0\r\x01\n\n\n\x03\x04\x01\x01\x12\x03\x07\
\x01\x01\x12\x03\x08\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x08\ \x08\x0b\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x08\x04\x12\n\x0c\n\x05\x04\
\x12\x13\n\x0b\n\x04\x04\x01\x02\x02\x12\x03\t\x04\x17\n\x0c\n\x05\x04\ \x01\x02\0\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\
\x01\x02\x02\x05\x12\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\ \x08\x0b\r\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x08\x10\x11\n\x0b\n\x04\
\t\x0b\x12\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\t\x15\x16b\x06proto3\ \x04\x01\x02\x01\x12\x03\t\x04\x14\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\
\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\t\x0b\x0f\n\x0c\n\
\x05\x04\x01\x02\x01\x03\x12\x03\t\x12\x13\n\x0b\n\x04\x04\x01\x02\x02\
\x12\x03\n\x04\x14\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\n\x04\n\n\x0c\
\n\x05\x04\x01\x02\x02\x01\x12\x03\n\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x02\
\x03\x12\x03\n\x12\x13\n\x0b\n\x04\x04\x01\x02\x03\x12\x03\x0b\x04\x14\n\
\x0c\n\x05\x04\x01\x02\x03\x05\x12\x03\x0b\x04\n\n\x0c\n\x05\x04\x01\x02\
\x03\x01\x12\x03\x0b\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\x0b\
\x12\x13\n\x0b\n\x04\x04\x01\x02\x04\x12\x03\x0c\x04\x17\n\x0c\n\x05\x04\
\x01\x02\x04\x05\x12\x03\x0c\x04\n\n\x0c\n\x05\x04\x01\x02\x04\x01\x12\
\x03\x0c\x0b\x12\n\x0c\n\x05\x04\x01\x02\x04\x03\x12\x03\x0c\x15\x16b\
\x06proto3\
"; ";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -0,0 +1,243 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `doc_query.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct QueryDocRequest {
// message fields
pub doc_id: ::std::string::String,
pub read_content: bool,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a QueryDocRequest {
fn default() -> &'a QueryDocRequest {
<QueryDocRequest as ::protobuf::Message>::default_instance()
}
}
impl QueryDocRequest {
pub fn new() -> QueryDocRequest {
::std::default::Default::default()
}
// string doc_id = 1;
pub fn get_doc_id(&self) -> &str {
&self.doc_id
}
pub fn clear_doc_id(&mut self) {
self.doc_id.clear();
}
// Param is passed by value, moved
pub fn set_doc_id(&mut self, v: ::std::string::String) {
self.doc_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_doc_id(&mut self) -> &mut ::std::string::String {
&mut self.doc_id
}
// Take field
pub fn take_doc_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.doc_id, ::std::string::String::new())
}
// bool read_content = 2;
pub fn get_read_content(&self) -> bool {
self.read_content
}
pub fn clear_read_content(&mut self) {
self.read_content = false;
}
// Param is passed by value, moved
pub fn set_read_content(&mut self, v: bool) {
self.read_content = v;
}
}
impl ::protobuf::Message for QueryDocRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.doc_id)?;
},
2 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
let tmp = is.read_bool()?;
self.read_content = tmp;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.doc_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.doc_id);
}
if self.read_content != false {
my_size += 2;
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.doc_id.is_empty() {
os.write_string(1, &self.doc_id)?;
}
if self.read_content != false {
os.write_bool(2, self.read_content)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> QueryDocRequest {
QueryDocRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"doc_id",
|m: &QueryDocRequest| { &m.doc_id },
|m: &mut QueryDocRequest| { &mut m.doc_id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
"read_content",
|m: &QueryDocRequest| { &m.read_content },
|m: &mut QueryDocRequest| { &mut m.read_content },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<QueryDocRequest>(
"QueryDocRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static QueryDocRequest {
static instance: ::protobuf::rt::LazyV2<QueryDocRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(QueryDocRequest::new)
}
}
impl ::protobuf::Clear for QueryDocRequest {
fn clear(&mut self) {
self.doc_id.clear();
self.read_content = false;
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for QueryDocRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for QueryDocRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0fdoc_query.proto\"K\n\x0fQueryDocRequest\x12\x15\n\x06doc_id\x18\
\x01\x20\x01(\tR\x05docId\x12!\n\x0cread_content\x18\x02\x20\x01(\x08R\
\x0breadContentJ\x98\x01\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\
\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\
\x12\x03\x02\x08\x17\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x16\n\x0c\n\
\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\0\x01\x12\
\x03\x03\x0b\x11\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x14\x15\n\x0b\n\
\x04\x04\0\x02\x01\x12\x03\x04\x04\x1a\n\x0c\n\x05\x04\0\x02\x01\x05\x12\
\x03\x04\x04\x08\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\t\x15\n\x0c\n\
\x05\x04\0\x02\x01\x03\x12\x03\x04\x18\x19b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -72,10 +72,10 @@ impl ::protobuf::reflect::ProtobufValue for EditorEvent {
static file_descriptor_proto_data: &'static [u8] = b"\ static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0bevent.proto*\x1c\n\x0bEditorEvent\x12\r\n\tCreateDoc\x10\0JS\n\x06\ \n\x0bevent.proto*\x1c\n\x0bEditorEvent\x12\r\n\tCreateDoc\x10\0JS\n\x06\
\x12\x04\0\0\x03\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\ \x12\x04\0\0\x04\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\
\x04\x01\0\x03\x01\n\n\n\x03\x05\0\x01\x12\x03\x01\x05\x10\n\x0b\n\x04\ \x04\x02\0\x04\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x10\n\x0b\n\x04\
\x05\0\x02\0\x12\x03\x02\x04\x12\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x02\ \x05\0\x02\0\x12\x03\x03\x04\x12\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\
\x04\r\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x02\x10\x11b\x06proto3\ \x04\r\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x10\x11b\x06proto3\
"; ";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -8,3 +8,6 @@ pub use errors::*;
mod event; mod event;
pub use event::*; pub use event::*;
mod doc_query;
pub use doc_query::*;

View File

@ -1,11 +1,14 @@
syntax = "proto3"; syntax = "proto3";
message CreateDocRequest { message CreateDocRequest {
string view_id = 1; string id = 1;
string name = 2; string name = 2;
string desc = 3;
} }
message Doc { message Doc {
string id = 1; string id = 1;
string name = 2; string name = 2;
string view_id = 3; string desc = 3;
string path = 4;
string content = 5;
} }

View File

@ -0,0 +1,6 @@
syntax = "proto3";
message QueryDocRequest {
string doc_id = 1;
bool read_content = 2;
}

View File

@ -1,4 +1,5 @@
syntax = "proto3"; syntax = "proto3";
enum EditorEvent { enum EditorEvent {
CreateDoc = 0; CreateDoc = 0;
} }

View File

@ -0,0 +1,40 @@
use crate::{
errors::EditorError,
module::EditorDatabase,
sql_tables::doc::{DocTable, DocTableChangeset},
};
use flowy_database::{
prelude::*,
schema::{doc_table, doc_table::dsl},
};
use std::sync::Arc;
pub struct DocTableSql {
pub database: Arc<dyn EditorDatabase>,
}
impl DocTableSql {
pub(crate) fn write_doc_table(&self, doc_table: DocTable) -> Result<(), EditorError> {
let conn = self.database.db_connection()?;
let _ = diesel::insert_into(doc_table::table)
.values(doc_table)
.execute(&*conn)?;
Ok(())
}
pub(crate) fn update_doc_table(&self, changeset: DocTableChangeset) -> Result<(), EditorError> {
let conn = self.database.db_connection()?;
diesel_update_table!(doc_table, changeset, conn);
Ok(())
}
pub(crate) fn read_doc_table(&self, doc_id: &str) -> Result<DocTable, EditorError> {
let doc_table = dsl::doc_table
.filter(doc_table::id.eq(doc_id))
.first::<DocTable>(&*(self.database.db_connection()?))?;
Ok(doc_table)
}
pub(crate) fn delete_doc(&self, view_id: &str) -> Result<(), EditorError> { unimplemented!() }
}

View File

@ -0,0 +1,61 @@
use crate::entities::doc::{CreateDocParams, Doc, UpdateDocParams};
use flowy_database::schema::doc_table;
use flowy_infra::{timestamp, uuid};
use std::convert::TryInto;
#[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)]
#[table_name = "doc_table"]
pub(crate) struct DocTable {
pub id: String,
pub name: String,
pub desc: String,
pub path: String,
pub modified_time: i64,
pub create_time: i64,
pub version: i64,
}
impl DocTable {
pub fn new(params: CreateDocParams) -> Self {
let time = timestamp();
Self {
id: params.id,
name: params.name,
desc: params.desc,
path: "".to_owned(),
modified_time: time,
create_time: time,
version: 0,
}
}
}
#[derive(AsChangeset, Identifiable, Default, Debug)]
#[table_name = "doc_table"]
pub(crate) struct DocTableChangeset {
pub id: String,
pub name: Option<String>,
pub desc: Option<String>,
}
impl DocTableChangeset {
pub(crate) fn new(params: UpdateDocParams) -> Self {
Self {
id: params.id,
name: params.name,
desc: params.desc,
}
}
}
impl std::convert::Into<Doc> for DocTable {
fn into(self) -> Doc {
Doc {
id: self.id,
name: self.name,
desc: self.desc,
path: self.path,
content: "".to_string(),
}
}
}

View File

@ -0,0 +1,5 @@
mod doc_sql;
mod doc_table;
pub use doc_sql::*;
pub use doc_table::*;

View File

@ -0,0 +1 @@
pub mod doc;

View File

@ -0,0 +1 @@
mod doc_test;