Warn
POD ERRORS here is normal because DBIx::POS::Template used.
Mojolicious::Plugin::RoutesAuthDBI::POS::Pg
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
NAME
Mojolicious::Plugin::RoutesAuthDBI::POS::Pg - POS for PostgreSQL.
DB DESIGN DIAGRAM
See https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/blob/master/Diagram.svg
SYNOPSIS
use DBIx::POS::Template;
my @path = split(/\//, __FILE__ );
my $file = join('/', @path[0 .. $#path -1], 'POS/Pg.pm');
my $pos = DBIx::POS::Template->new($file,);
my $sth = $dbh->prepare($pos->{'user'});
SEE ALSO
SQL definitions
For access methods
user
{cached=>1}
select * from {% $schema %}users where id = ? or login=?
apply routes
select r.*, ac.controller, ac.namespace, ac.action, ac.callback, ac.id as action_id, ac.controller_id, ac.namespace_id from {% $schema %}routes r join {% $schema %}refs rf on r.id=rf.id1 join ( select a.*, c.* from {% $schema %}actions a left join ( select r.id2 as _id, c.controller, c.id as controller_id, n.namespace, n.id as namespace_id from {% $schema %}refs r join {% $schema %}controllers c on r.id1=c.id left join {% $schema %}refs r2 on c.id=r2.id2 left join {% $schema %}namespaces n on n.id=r2.id1 ) c on a.id=c._id ) ac on rf.id2=ac.id order by r.ts - (coalesce(r.interval_ts, 0::int)::varchar || ' second')::interval;
user roles
{cached=>1}
select g.* from {% $schema %}roles g join {% $schema %}refs r on g.id=r.id1 where r.id2=?; --and coalesce(g.disable, 0::bit) <> 1::bit
cnt refs
{cached=>1}
select count(*) from {% $schema %}refs where id1 = any(?) and id2 = ANY(?);
access action
{cached=>1}
select count(r.*) from {% $schema %}refs rc join {% $schema %}actions a on a.id=rc.id2 join {% $schema %}refs r on a.id=r.id1 ---join {% $schema %}roles o on o.id=r.id2 where rc.id1=? ---controller id and a.action=? and r.id2=any(?) --- roles ids ---and coalesce(o.disable, 0::bit) <> 1::bit ;
access namespace
{cached=>1}
select count(n.*) from {% $schema %}namespaces n join {% $schema %}refs r on n.id=r.id1 ---join {% $schema %}roles o on r.id2=o.id where n.namespace=? and r.id2=any(?) --- roles ids ---and coalesce(o.disable, 0::bit) <> 1::bit ;
access role
{cached=>1}
select count(*) from {% $schema %}roles where (id = ? or name = ?) and id = any(?) and coalesce(disable, 0::bit) <> 1::bit ;
For administration actions (controller)
new user
insert into {% $schema %}users (login, pass) values (?,?) returning *;
role
select * from {% $schema %}roles where id=? or lower(name)=?
new role
insert into {% $schema %}roles (name) values (?) returning *;
dsbl/enbl role
update {% $schema %}roles set disable=?::bit where id=? or lower(name)=? returning *;
ref
select * from {% $schema %}refs where id1=? and id2=?;
new ref
insert into {% $schema %}refs (id1,id2) values (?,?) returning *;
del ref
delete from {% $schema %}refs where id1=? and id2=? returning *;
controller
{cached=>1}
select * from ( select c.*, n.namespace, n.id as namespace_id, n.descr as namespace_descr from {% $schema %}controllers c left join {% $schema %}refs r on c.id=r.id2 left join {% $schema %}namespaces n on n.id=r.id1 ) s {% $where %}
new controller
insert into {% $schema %}controllers (controller, descr) values (?,?) returning *;
action routes
select * from ( select r.*, s.action_id from {% $schema %}routes r left join ( select s.id1, a.id as action_id from {% $schema %}refs s join {% $schema %}actions a on a.id=s.id2 ) s on r.id=s.id1 ) s {% $where %}; -- action_id is null - free routes; or action(id) routes ;
new route
insert into {% $schema %}routes (request, name, descr, auth, disable, interval_ts) values (?,?,?,?,?,?) returning *;
role users
select u.* from {% $schema %}users u join {% $schema %}refs r on u.id=r.id2 where r.id1=?;
role routes
select t.* from {% $schema %}routes t join {% $schema %}refs r on t.id=r.id1 where r.id2=?;
controllers
select c.*, n.namespace, n.id as namespace_id, n.descr as namespace_descr from {% $schema %}controllers c left join {% $schema %}refs r on c.id=r.id2 left join {% $schema %}namespaces n on n.id=r.id1 {% $where %};
namespaces
select * from {% $schema %}namespaces {% $where %} {% $order %};
namespace
select * from {% $schema %}namespaces where id=? or namespace = ?;
new namespace
insert into {% $schema %}namespaces (namespace, descr, app_ns, interval_ts) values (?,?,?,?) returning *;
actions
select * from ( select a.*, ac.controller_id, ac.controller from {% $schema %}actions a left join ( select a.id, c.id as controller_id, c.controller from {% $schema %}actions a join {% $schema %}refs r on a.id=r.id2 join {% $schema %}controllers c on c.id=r.id1 ) ac on a.id=ac.id-- действия с контроллером ) as a {% $where %}
new action
insert into {% $schema %}actions (action, callback, descr) values (?,?,?) returning *;
тест
ыудусе * акщь тест!ж
88 POD Errors
The following errors were encountered while parsing the POD:
- Around line 44:
Unknown directive: =name
- Around line 46:
Unknown directive: =desc
- Around line 48:
Unknown directive: =param
- Around line 52:
Unknown directive: =sql
- Around line 60:
Unknown directive: =name
- Around line 62:
Unknown directive: =desc
- Around line 64:
Unknown directive: =sql
- Around line 86:
Unknown directive: =name
- Around line 88:
Unknown directive: =desc
- Around line 90:
Unknown directive: =param
- Around line 94:
Unknown directive: =sql
- Around line 105:
Unknown directive: =name
- Around line 107:
Unknown directive: =desc
- Around line 109:
Unknown directive: =param
- Around line 113:
Unknown directive: =sql
- Around line 121:
Unknown directive: =name
- Around line 123:
Unknown directive: =desc
- Around line 125:
Unknown directive: =param
- Around line 129:
Unknown directive: =sql
- Around line 147:
Unknown directive: =name
- Around line 149:
Unknown directive: =desc
- Around line 151:
Unknown directive: =param
- Around line 155:
Unknown directive: =sql
- Around line 170:
Unknown directive: =name
- Around line 172:
Unknown directive: =desc
- Around line 174:
Unknown directive: =param
- Around line 178:
Unknown directive: =sql
- Around line 195:
Unknown directive: =name
- Around line 197:
Unknown directive: =desc
- Around line 199:
Unknown directive: =sql
- Around line 206:
Unknown directive: =name
- Around line 208:
Unknown directive: =desc
- Around line 210:
Unknown directive: =sql
- Around line 218:
Unknown directive: =name
- Around line 220:
Unknown directive: =desc
- Around line 222:
Unknown directive: =sql
- Around line 229:
Unknown directive: =name
- Around line 231:
Unknown directive: =desc
- Around line 233:
Unknown directive: =sql
- Around line 240:
Unknown directive: =name
- Around line 242:
Unknown directive: =desc
- Around line 244:
Unknown directive: =sql
- Around line 252:
Unknown directive: =name
- Around line 254:
Unknown directive: =desc
- Around line 256:
Unknown directive: =sql
- Around line 264:
Unknown directive: =name
- Around line 266:
Unknown directive: =desc
- Around line 268:
Unknown directive: =sql
- Around line 276:
Unknown directive: =name
- Around line 278:
Unknown directive: =desc
- Around line 280:
Unknown directive: =param
- Around line 284:
Unknown directive: =sql
- Around line 297:
Unknown directive: =name
- Around line 299:
Unknown directive: =desc
- Around line 301:
Unknown directive: =sql
- Around line 309:
Unknown directive: =name
- Around line 311:
Unknown directive: =desc
- Around line 313:
Unknown directive: =sql
- Around line 330:
Unknown directive: =name
- Around line 332:
Unknown directive: =desc
- Around line 334:
Unknown directive: =sql
- Around line 342:
Unknown directive: =name
- Around line 344:
Unknown directive: =desc
- Around line 346:
Unknown directive: =sql
- Around line 356:
Unknown directive: =name
- Around line 358:
Unknown directive: =desc
- Around line 360:
Unknown directive: =sql
- Around line 371:
Unknown directive: =name
- Around line 373:
Unknown directive: =desc
- Around line 375:
Unknown directive: =sql
- Around line 385:
Unknown directive: =name
- Around line 387:
Unknown directive: =desc
- Around line 389:
Unknown directive: =sql
- Around line 398:
Unknown directive: =name
- Around line 400:
Unknown directive: =desc
- Around line 402:
Unknown directive: =sql
- Around line 410:
Unknown directive: =name
- Around line 412:
Unknown directive: =desc
- Around line 414:
Unknown directive: =sql
- Around line 422:
Unknown directive: =name
- Around line 424:
Unknown directive: =desc
- Around line 426:
Unknown directive: =sql
- Around line 442:
Unknown directive: =name
- Around line 444:
Unknown directive: =desc
- Around line 446:
Unknown directive: =sql
- Around line 455:
Unknown directive: =name
- Around line 457:
Unknown directive: =desc
- Around line 459:
Unknown directive: =sql