Systems that utilize a database benefit from an automated means of translating database CRUD operations to application language.
Products like 'ObjectStore' aim to provide mechanisms to exchange data to/from applications to the database in a seamless fashion.
This can be done by providing the means of converting C++ objects into SQL query/insert/update commands and converting query responses back into C++ objects.
My SQL-fu being significantly rusty, I spend a bit of time attempting to create an ORM/MySql project go get a better understanding on how such a product could be created.
If we take the tact of most 'language-independent' products, we can start with a language-independent intermediary language, one that allows us to define the type of objects we wish to store/retrieve from the database.
A db-object file (e.g. MyDb.odb) can specify a database object as follows:
dbclass MyRecord002
float val01 as key;
end;
This odb file can then be pre-processed, creating a language-dependent library components (MyDb.h, MyDb.cpp) which can then be used by applications directly. Updates to the library component can automatically be applied in the database. The linked association between the C++ object and the database are enforced by constructors and access methods.
A bit of proof-of-concept at this time, works for a handful of data types {int, float, long, text, char(X)}, soon to add date/time. At this time, constrained to 'flat' datatypes, but *fingers-crossed* to work for nested datatypes in the future.
https://github.com/fsk-software/pub/tree/master/DbObjOverlay
Recently came across Wt::Dbo reference as well, haven't had a chance to take a look yet; https://www.webtoolkit.eu/wt/doc/tutorial/dbo.html
No comments:
Post a Comment