HerikLyma / CPPWebFramework

​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
MIT License
445 stars 119 forks source link

Basic orm classes #24

Closed Syllll closed 5 years ago

Syllll commented 5 years ago

Pull Request Checklist

Please check if your Pull Request fulfills the following requirements:

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other (Please describe)

What is the current behavior?

CWF is awesome but lacks ORM and entity management features.

What is the new behavior?

New classes implements a basic ORM that could be extended in the future work. Currently, the little orm works only with sqlite. It should be easy to make it works with SQL and PostGres as only a few string should be changed in the sqlquerymanager class.

The ORM functionalities are inspired from my experience with Symfony (php framework, see doctrine) and NodeJS (Sequelize orm).

Does this Pull Request introduce a breaking change?

[ ] Yes
[x] No

Other information

The features added by this pull should really be extended and made more robust (full sql compatibility). Note the model classes reimplements some features of the metaclassparser but in a slightly different way: model is able to detect the properties of a given Qt object and of its base class(es). Thus, the list of properties returned internally is complete even if inheritance is used between models.

Overall, feel free to edit or comment. I will take all remarks with a positive mindset and I am happy to contribute to the project.

Syllll commented 5 years ago

OK, nice for the checks. However, I am not sure the static in the namespace if entirely a good idea (see last commit). The idea is for a user to put content in the namespace at startup :

_CWF::SqlDatabaseStorage CWF::DbStorage::_storage("QSQLITE", // type of the database "localhost", // host of the database dbAppPath, // Name or path to the database "toto", // username "rere", // password 3306 // port 5432 ); QString CWF::DbStorage::secret = "sedqddqzdif";

I will let you think about this ;-).

HerikLyma commented 5 years ago

Thank you my friend, I'm going to rewiew.