NAME

Mojo::Hakkefuin::Backend - Backend base class

SYNOPSIS

package Mojo::Hakkefuin::Backend::MyBackend;
use Mojo::Base 'Mojo::Hakkefuin::Backend';

sub table_query   { ... }
sub check_table   { ... }
sub create_table  { ... }
sub empty_table   { ... }
sub drop_table    { ... }

sub create        { ... }
sub read          { ... }
sub update        { ... }
sub update_csrf   { ... }
sub update_cookie { ... }
sub upd_coolock   { ... }
sub upd_lckstate  { ... }
sub delete        { ... }
sub check         { ... }

DESCRIPTION

Mojo::Hakkefuin::Backend is an abstract base class for Mojo::Hakkefuin backends, like Mojo::Hakkefuin::Backend::sqlite.

ATTRIBUTES

Mojo::Hakkefuin::Backend implements the following attributes.

dsn

# list of dsn support :
- mysql://username:password@hostname:port/database
- mariadb://username:password@hostname:port/database
- postgresql://username:password@hostname:port/database

# Example use as a config
my $backend = Mojo::Hakkefuin::Backend::mariadb->new(
  ...
  dsn => 'protocols://username:password@hostname:port/database',
  ...
);

# use as a method
my $backend = $backend->dsn;
$backend->dsn('protocols://username:password@hostname:port/database');

This attribute for specify Data Source Name for DBMS, e.g. MariaDB/MySQL or PostgreSQL. dsn attribute can be use as a config or method.

dir

# Example use as a config
my $backend = Mojo::Hakkefuin::Backend::mariadb->new(
  ...
  dir => '/home/user/mojo/app/path/',
  ...
);

# use as a method
my $backend = $backend->dir;
$backend->dir('/home/user/mojo/app/path/');

This attribute for specify path (directory address) of directory SQLite database file or migrations configuration file.

TABLE FIELD ATTRIBUTES

The attributes for Table Field will be used on method table_query. In the future the user can determine the name dynamically from the field table.

my $table_field = [
  $self->table_name,
  $self->id,
  $self->identify,
  $self->cookie,
  $self->csrf,
  $self->create_date,
  $self->expire_date,
  $self->cookie_lock,
  $self->lock
];

Now this attributes only used by method table_query.

METHODS

Mojo::Hakkefuin::Backend inherits all methods from Mojo::Base and implements the following new ones. In this module contains 2 section methods that is Table Interaction and Data Interaction.

Table Interaction

A section for all activities related to interaction data in a database table.

table_query

my $table_query = $backend->table_query;
$backend->table_query;

This method used by the create_table method to generate a query that will be used to create a database table.

check_table

$backend->check_table();
my $check_table = $backend->check_table;

This method is used to check whether a table in the DBMS exists or not

create_table

$backend->create_table();
my $create_table = $backend->create_table;

This method is used to create database table.

empty_table

$backend->empty_table;
my $empty_table = $backend->empty_table;

This method is used to delete all database table (It means to delete all data in a table).

drop_table

$backend->drop_table;
my $drop_table = $backend->drop_table;

This method is used to drop database table (It means to delete all data in a table and its contents).

Data Interaction

A section for all activities related to data interaction in a database table. These options are currently available:

$id

A variable containing a unique id that is generated when inserting data into a table.

$identify

The variables that contain important information for data login but not crucial information.

$cookie

The variable that contains the cookie hash, which hash is used in the HTTP header.

$csrf

The variable that contains the csrf token hash, which hash is used in the HTTP header.

$expires

The variable that contains timestamp format. e.g. 2023-03-23 12:01:53. For more information see Mojo::Hakkefuin::Utils.

create($identify, $cookie, $csrf, $expires)

$backend->create($identify, $cookie, $csrf, $expires)

Method for insert data login.

read($identify, $cookie)

$backend->read($identify, $cookie);

Method for read data login.

update()

$backend->update($id, $cookie, $csrf);

Method for update data login.

update_csrf()

$backend->update_csrf($id, $csrf);

Method for update CSRF token login.

update_cookie()

$backend->update_cookie($id, $cookie);

Method for update cookie login.

upd_coolock()

$backend->upd_coolock();

Method for update cookie lock session.

upd_lckstate()

$backend->upd_lckstate();

Method for update lock state condition.

delete($identify, $cookie)

$backend->delete($identify, $cookie);

Method for delete data login.

check($identify, $cookie)

$backend->check($identify, $cookie);

Method for check data login.

SEE ALSO