12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- use crate::entities::doc::{Doc, UpdateDocParams};
- use flowy_database::schema::doc_table;
- #[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)]
- #[table_name = "doc_table"]
- pub(crate) struct DocTable {
- pub id: String,
- pub data: Vec<u8>,
- pub revision: i64,
- }
- impl DocTable {
- pub fn new(doc: Doc) -> Self {
- Self {
- id: doc.id,
- data: doc.data,
- revision: 0,
- }
- }
- }
- #[derive(AsChangeset, Identifiable, Default, Debug)]
- #[table_name = "doc_table"]
- pub(crate) struct DocTableChangeset {
- pub id: String,
- pub data: Vec<u8>,
- }
- impl DocTableChangeset {
- pub(crate) fn new(params: UpdateDocParams) -> Self {
- Self {
- id: params.id,
- data: params.doc_data,
- }
- }
- }
- impl std::convert::Into<Doc> for DocTable {
- fn into(self) -> Doc {
- Doc {
- id: self.id,
- data: self.data,
- revision: self.revision,
- }
- }
- }
|