Skip to content

Database Refactor

Alex Karasulu edited this page Mar 21, 2018 · 3 revisions

What is this ?

Gorjun's database is described (partially) here.

The Problem

We deal direct with data from the database, basically, we don't have any abstractions around. As an example:

https://github.com/subutai-io/cdn/blob/master/download/download.go#L128-L219

These lines defines Info() function. That should perform a search on database for specific model data. In order to do it, he uses https://github.com/subutai-io/cdn/blob/master/db/db.go functions direct. So each part of code that needs information from database, introduce a new argument or modifies code on database functions. But this leads to incompatible code for other parts that deals direct with the database handler.

Solution

Gorjun needs to deal with abstract models: such as Templates, Package and RawFiles and others, so that models deals with database in a proper manner, leaving room to database beign changed without other parts of gorjun breaks. So we stuck with a good interface between code that use our model and how model persist on database, this is well known issue on all web applications, and stuck as the ORM model. And is a good separation of concerns.