Page 1 of 1

[Demo] Storing TRichView using Synopse mORMot framework (SQLite3)

Posted: Mon Jul 02, 2018 2:41 pm
by Sergey Tkachenko
This is a simple demo project showing how to store TRichView data using Synopse mORMot framework
(4.57 KiB) Downloaded 834 times

It stores TRichView in two fields:
- Document (BLOB field, stored as RVF)
- PlainText (UTF-8 text field, could be used for text searching)

SQLite3-Demo.png (12.31 KiB) Viewed 15677 times

This demo is based on the mORMot demo from "SQLite3\Samples\02 - Embedded SQLite3 ORM" folder.

Re: [Demo] Storing TRichView using Synopse mORMot framework (SQLite3)

Posted: Mon Jul 02, 2018 3:22 pm
by richrich
Thank you.
As data is going to be bigger smaller file size is preferred
so I'm not sure if that's good option to store in one db two versions of the same data

What about using DB version or T(DB)RichEditView ?
What is the differenct for same purpose to use DB and normal RichEditView?

Re: [Demo] Storing TRichView using Synopse mORMot framework (SQLite3)

Posted: Mon Jul 02, 2018 4:01 pm
by Sergey Tkachenko
1. The actual document is stored in RVF format, which is binary format, and it is stored in BLOB field. I am afraid it is not possible to search for text in BLOB fields (especially considering the fact that it contains not only text but images, font properties, control codes, etc.).
So I think a plain text version is necessary, if you want to search in this text.

I can imagine the following alternatives:
- searching by enumerating each record in a database, loading record content in TRichView one by one, and searching in TRichView. Slow!
- inventing your own plain text format for data saving (for example, like in Chat codes demo). But if you keep this format simple, you will be able to store only simple formatting properties.

2. When document is edited in TRichViewEdit, you call its method for storing/loading it in a file, stream, database, etc.
TDBRichViewEdit works like other Delphi DB controls: TDBEdit, TDBMemo, etc. It can be linked to a database field by assigning its DataSource and DataField properties, and documents are stored/loaded from DB automatically (with help of TDBNavigator component or its analog).
TDBRichViewEdit can work only together with dataset components (inherited from TDataSet).
SQLite3 may include such component, but, AFAIK, it's designed mainly to support legacy applications, and it is not recommended for using. So I suggest using TRichViewEdit with SQLite3.