Class (GI Struct)

GLib-2.0GLibRelationAbstractDeprecated 2.26

A GLib.Relation is a table of data which can be indexed on any number of fields, rather like simple database tables. A GLib.Relation contains a number of records, called tuples. Each record contains a number of fields. Records are not ordered, so it is not possible to find the record at a particular index.

Note that GLib.Relation tables are currently limited to 2 fields.

To create a GLib.Relation, use GLib.Relation.new.

To specify which fields should be indexed, use GLib.Relation.index. Note that this must be called before any tuples are added to the GLib.Relation.

To add records to a GLib.Relation use GLib.Relation.insert.

To determine if a given record appears in a GLib.Relation, use GLib.Relation.exists. Note that fields are compared directly, so pointers must point to the exact same position (i.e. different copies of the same string will not match.)

To count the number of records which have a particular value in a given field, use GLib.Relation.count.

To get all the records which have a particular value in a given field, use GLib.Relation.select. To access fields of the resulting records, use GLib.Tuples.index. To free the resulting records use GLib.Tuples.destroy.

To delete all records which have a particular value in a given field, use GLib.Relation.delete.

To destroy the GLib.Relation, use GLib.Relation.destroy.

To help debug GLib.Relation objects, use GLib.Relation.print.

GLib.Relation has been marked as deprecated, since this API has never been fully implemented, is not very actively maintained and rarely used.

since 2.26: Rarely used API

Index

Constructors

Properties

Methods

Constructors

Properties

Methods

  • Returns the number of tuples in a GLib.Relation that have the given value in the given field.

    Parameters

    • Deprecatedkey: any

      the value to compare with.

    • Deprecatedfield: number

      the field of each record to match.

    Returns number

    the number of matches.

  • Deletes any records from a GLib.Relation that have the given key value in the given field.

    Parameters

    • Deprecatedkey: any

      the value to compare with.

    • Deprecatedfield: number

      the field of each record to match.

    Returns number

    the number of records deleted.

  • Destroys the GLib.Relation, freeing all memory allocated. However, it does not free memory allocated for the tuple data, so you should free that first if appropriate.

    Returns void