MidgardStorage

MidgardStorage — Underlying storage creator

Synopsis


#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);

Object Hierarchy

  GObject
   +----midgard_storage

Description

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.

Details

midgard_storage

typedef struct _MidgardStorage midgard_storage;


MidgardStorage

typedef struct _MidgardStorage MidgardStorage;

Since 9.09


MidgardStorageClass

typedef struct _MidgardStorageClass MidgardStorageClass;

Since 9.09


midgard_storage_create_base_storage ()

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.

mgd :

MidgardConnection instance

Returns :

TRUE if tables has been created, FALSE otherwise.

Since 9.09


midgard_storage_create_class_storage ()

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

mgd :

MidgardConnection instance

klass :

MidgardDBObjectClass pointer

Returns :

TRUE on success, FALSE otherwise

Since 9.09


midgard_storage_update_class_storage ()

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.

mgd :

MidgardConnection instance

klass :

MidgardDBObjectClass pointer

Returns :

TRUE on success, FALSE otherwise

Since 9.09


midgard_storage_class_storage_exists ()

gboolean            midgard_storage_class_storage_exists
                                                        (MidgardConnection *mgd,
                                                         MidgardDBObjectClass *klass);

Checks whether storage for given klass exists.

mgd :

MidgardConnection instance

klass :

MidgardDBObjectClass pointer

Returns :

TRUE if storage exists, FALSE otherwise

Since 9.09


midgard_storage_delete_class_storage ()

gboolean            midgard_storage_delete_class_storage
                                                        (MidgardConnection *mgd,
                                                         MidgardDBObjectClass *klass);

Delete storage for given klass.

mgd :

MidgardConnection instance

klass :

MidgardDBObjectClass pointer

Returns :

TRUE on success, FALSE otherwise

Since 9.09