package Daje::Helper::Authorities::InsertPluginFunction;
use Mojo::Base -base, -signatures;
use v5.42;

# NAME
# ====
#
# Daje::Helper::Authorities::InsertPluginFunction - Daje helper
#
# SYNOPSIS
# ========
#
#
# DESCRIPTION
# ===========
#
# Daje::Helper::Authorities::InsertPluginFunction a helper clas
#
# METHODS
# =======
#
#
#
#
# SEE ALSO
# ========
#
# Mojolicious, Mojolicious::Guides, https://mojolicious.org.
#
# LICENSE
# =======
#
# Copyright (C) janeskil1525.
#
# This library is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# AUTHOR
# ======
#
# janeskil1525 E<lt>janeskil1525@gmail.com
#

has 'db';

sub process($self, $plugin, $functions) {

    $self->db->query("INSERT INTO authorities_plugin (name) VALUES (?) ON CONFLICT(name) DO NOTHING",($plugin));

    my $stmt = qq{
                    INSERT INTO authorities_function (name, authorities_plugin_fkey)
                        VALUES (?,( SELECT authorities_plugin_pkey FROM authorities_plugin WHERE name = ? ))
                    ON CONFLICT (name) DO NOTHING
    };

    my $length = scalar @{$functions};
    for (my $i = 0; $i < $length; $i++) {
        $self->db->query($stmt,(@{$functions}[$i], $plugin));
    }
}

1;


#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################

=head1 NAME


Daje::Helper::Authorities::InsertPluginFunction - Daje helper



=head1 SYNOPSIS





=head1 DESCRIPTION


Daje::Helper::Authorities::InsertPluginFunction a helper clas



=head1 REQUIRES

L<v5.42> 

L<Mojo::Base> 


=head1 METHODS







=head1 SEE ALSO


Mojolicious, Mojolicious::Guides, https://mojolicious.org.



=head1 AUTHOR


janeskil1525 E<lt>janeskil1525@gmail.com



=head1 LICENSE


Copyright (C) janeskil1525.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.



=cut

