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

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post by Sergey Tkachenko »

This is a simple demo project showing how to store TRichView data using Synopse mORMot framework

SQLite3-Demo.zip
(4.57 KiB) Downloaded 4390 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
SQLite3-Demo.png (12.31 KiB) Viewed 58519 times

This demo is based on the mORMot demo from "SQLite3\Samples\02 - Embedded SQLite3 ORM" folder.
richrich
Posts: 5
Joined: Sun Jul 01, 2018 2:51 pm

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

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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.
Post Reply