| Midgard2 Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | ||||
#include <midgard/midgard.h> typedef midgard_storage; MidgardStorage; MidgardStorageClass; gboolean midgard_storage_create_base_storage (MidgardConnection *mgd); gboolean midgard_storage_create_class_storage (MidgardConnection *mgd, MidgardDBObjectClass *klass); gboolean midgard_storage_update_class_storage (MidgardConnection *mgd, MidgardDBObjectClass *klass); gboolean midgard_storage_class_storage_exists (MidgardConnection *mgd, MidgardDBObjectClass *klass); gboolean midgard_storage_delete_class_storage (MidgardConnection *mgd, MidgardDBObjectClass *klass);
MidgardStorage is reponsible for creating underlying storage. It creates storage for every MidgardDBObjectClass derived one. For example, normal database tables are created for MidgardObjectClass derived classes, and database views for MidgardViewClass derived ones.
It is very important to understand that MidgardStorage doesn't have specific implementation which creates storage tables. Instead, it invokes private routines of MidgardDBObjectClass derived classes.
gboolean midgard_storage_create_base_storage (MidgardConnection *mgd);
Creates storage for base Midgard classes. Tables created by this method: repligard, midgard_user and midgard_person.
Since 9.09
gboolean midgard_storage_create_class_storage (MidgardConnection *mgd, MidgardDBObjectClass *klass);
Creates underlying storage (e.g. table in database) for given klass.
Given klass can be any MidgardDBObjectClass derived one.
It may be class which represents any underlying storage type.
For example, database table or view.
If underlying storage already exists, this method silently ignore creation
and returns TRUE. Such case is not considered an error.
This method also creates metadata storage if given class uses such.
Indexes are created if:
property is a link type
property is linked to another property
property is either parent or up
property holds guid value
Auto increment (and primary key ) field is created if property is defined as primaryproperty, and it's integer ( or unsigned one ) type
|
MidgardConnection instance |
|
MidgardDBObjectClass pointer |
Returns : |
TRUE on success, FALSE otherwise
|
Since 9.09
gboolean midgard_storage_update_class_storage (MidgardConnection *mgd, MidgardDBObjectClass *klass);
Update underlying storage, which is used by given klass.
This method doesn't create storage. It creates new columns if are defined
for klass properties and do not exist in storage yet.
See midgard_storage_create_class_storage() if you need more info about indexes.
|
MidgardConnection instance |
|
MidgardDBObjectClass pointer |
Returns : |
TRUE on success, FALSE otherwise
|
Since 9.09
gboolean midgard_storage_class_storage_exists (MidgardConnection *mgd, MidgardDBObjectClass *klass);
Checks whether storage for given klass exists.
|
MidgardConnection instance |
|
MidgardDBObjectClass pointer |
Returns : |
TRUE if storage exists, FALSE otherwise
|
Since 9.09