NAME

Bif::DB - helper methods for a read-only bif database

VERSION

0.1.5_5 (2015-08-13)

SYNOPSIS

    use strict;
    use warnings;
    use Bif::DB;

    # Bif::DB inherits from DBIx::ThinSQL, which inherits from DBI.
    my $db = Bif::DB->connect( $dsn );

    # Read only operations on a bif database:
    my @ids = $db->uuid2id( $uuid );

DESCRIPTION

Bif::DB is a DBI derivative that provides various read-only methods for retrieving information from a bif repository. For a read-write equivalent see Bif::DBW. The read-only and read-write parts are separated for performance reasons.

METHODS

uuid2id( $UUID ) -> List[Int]

Returns the (possibly multiple) integer ID(s) matching a node $UUID.

get_change( "$ID.$UPDATE_ID" ) -> HashRef

Looks up the change identified by $ID.$UPDATE_ID and returns undef or a hash reference containg the following keys:

  • id - the node ID

  • change_id - the ID of the change

  • kind - the type of the node

  • uuid - the universally unique identifier of the node

get_local_hub_id -> Int

Returns the ID for the local repository node.

get_projects( $PATH ) -> @HashRefs | \@HashRefs

Looks up the project(s) identified by $PATH (in [HUB/]PATH format) and returns a list of hash references containg the following keys:

  • id - the node ID

  • first_change_id - the change_id that created the node

  • kind - the type of the node

  • uuid - the universally unique identifier of the node

  • path - the path of the project

  • parent_id - the parent ID of the project

  • default_hub_id - the id of the project's default hub

  • hub_name - the name of the project's hub

  • local - true if the project is locally synchronized

The list is sorted by hub name then by project path.

NOTE: The underlying DBIx::ThinSQL method returns an Array References to the list in scalar context.

status_ids( $project_id, $kind, @status ) -> \@ids, \@invalid

Takes a project ID, a thread type (task, issue, etc) and a list of status names and returns an arrayref of matching IDs, and an arrayref of invalid names. This method will silently ignore any @status which are undefined.

get_hub( $name ) -> @HashRef

Returns a HASH reference containing information about the hub identified by $name with the following keys:

  • first_change_id - the first change ID

  • id - the node ID for the hub

  • location - the location of the hub

  • name - the name of the hub

  • path - the path of the hub node

  • uuid - the node unique identifier

Returns undef if $name (a name, an ID, or a location) is not found.

get_max_change_id

Returns the maximum change ID in the database.

check_fks

This is developer aide to print out foreign key relationship that are not satisfied (i.e. where the target row/column doesn't exist).

SEE ALSO

Bif::DBW

AUTHOR

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE

Copyright 2013-2015 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.