xtool/contrib/mORMot/SQLite3/Samples/01 - In Memory ORM/Project01.dpr

52 lines
1.7 KiB
ObjectPascal

{
Synopse mORMot framework
Sample 01 - In Memory ORM
purpose of this sample is to show the basic ORM usage of the framework:
- a TRecord class is defined in Unit1.pas
- a static server (i.e. in-memory database) is initialized (see
TSQLRestStorage.Create below);
it will store the data in a JSON file in the disk and won't require
the SQLite3 database engine
- the purpose of the form in Unit1.pas is to add a record to the
database; the Time field is filled with the current date and time
- the 'Find a previous message' button show how to perform a basic query
- on application quit, the Database.Destroy will update the JSON file
- since the framework use UTF-8 encoding, we use some basic functions for
fast conversion to/from the User Interface; in real applications,
you should better use our SQLite3i18n unit and the corresponding
TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
- note the tiny size of the EXE (since we don't use SQLite3), less than
80KB with LVCL :)
Version 1.0 - January 24, 2010
- Initial Release
Version 1.1 - April 14, 2011
- use TSQLRestStorageInMemory instead of abstract TSQLRestStorage
}
program Project01;
uses
{$I SynDprUses.inc} // use FastMM4 on older Delphi, or set FPC threads
Forms,
SysUtils,
SynCommons,
mORMot,
Unit1 in 'Unit1.pas' {Form1},
SampleData in 'SampleData.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Caption := ' Sample 01 - In Memory ORM';
Form1.Database := TSQLRestStorageInMemory.Create(TSQLSampleRecord,nil,
ChangeFileExt(ExeVersion.ProgramFileName,'.db'));
Application.Run;
end.