scala-db-model library is targeted towards creating a very flexible, automated migration , database independent ORM library for Scala. There are quite a few ORM libraries available for scala like 'scala-migrations', 'scala-active-records', 'squirl' etc. But none of them are spot on to the solution.
scala-db-model library is inspired by Django's ORM system which does all the migration work almost automatically without caring about the db level changes. Entire modifications have to be done on the class which is extending model and you are presented with ready-made scripts for migrations.
This library is in a very nascent phase so IS NOT RECOMMENDED FOR PRODUCTION USE.
(Initial draft)
+------------------+
| |
+---------+ MigrationManager +-------+
| | | |
| +------------------+ |
| |
+----+----+ +-------------------+ |
| | | | |
| DBModel +----+ QueryManager | |
| | | | |
+---------+ +-------+-----------+ |
| |
+-------+-----------+ |
| | |
| DBManager +------+
| |
+--------+----------+
|
+-v---+
| |
|-----|
| |
+-----+
Main class that will be extended by every class which is supposed to be mapped onto the database. This class will provide basic CRUD functionality for the class with some advanced features for searching records and all. Along with this, it will provide a feature of associating the model with other db models using standard relations
- one-to-one field
- one-to-many field
- many-to-one field
- many-to-many field
- many-to-many-with field with the feature of providing custom foreign key and other attributes via annotations. (Will check if possible with macros)
This is the only point from where DB communication will happen. So this class will generate db dependent queries. Initially we will start with postgres support. As the library matures we will go on adding more dbs.
This module will be responsible for creating, updating and performing migrations on the database via DBManager. Now as the only point of updating a table is class that is extending DBModel, it has to check before every compile that is there any change in the models and if there are any then detect the changes and create migration.
To make this library db independent we will have our own custom in-between queries, called faql (fake sql which are db independent). And they will be translated by db manager to the corresponding db based sql.
- DBModel
- Basic annotations for fields
- primary_key
- unique
- required
- transient
- Migration manager without change detection
- DB manager supporting Postgres
- Query manager with basic CRUD functionalities
Contact me at [email protected]