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
my $pos = Mojolicious::Plugin::RoutesAuthDBI::POS::Pg->new;
my $sth = $dbh->prepare($pos->{'user'});
Methods
One new()
new()
None input args for new.
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 54:
Unknown directive: =name
- Around line 56:
Unknown directive: =desc
- Around line 58:
Unknown directive: =param
- Around line 62:
Unknown directive: =sql
- Around line 70:
Unknown directive: =name
- Around line 72:
Unknown directive: =desc
- Around line 74:
Unknown directive: =sql
- Around line 96:
Unknown directive: =name
- Around line 98:
Unknown directive: =desc
- Around line 100:
Unknown directive: =param
- Around line 104:
Unknown directive: =sql
- Around line 115:
Unknown directive: =name
- Around line 117:
Unknown directive: =desc
- Around line 119:
Unknown directive: =param
- Around line 123:
Unknown directive: =sql
- Around line 131:
Unknown directive: =name
- Around line 133:
Unknown directive: =desc
- Around line 135:
Unknown directive: =param
- Around line 139:
Unknown directive: =sql
- Around line 157:
Unknown directive: =name
- Around line 159:
Unknown directive: =desc
- Around line 161:
Unknown directive: =param
- Around line 165:
Unknown directive: =sql
- Around line 180:
Unknown directive: =name
- Around line 182:
Unknown directive: =desc
- Around line 184:
Unknown directive: =param
- Around line 188:
Unknown directive: =sql
- Around line 205:
Unknown directive: =name
- Around line 207:
Unknown directive: =desc
- Around line 209:
Unknown directive: =sql
- Around line 216:
Unknown directive: =name
- Around line 218:
Unknown directive: =desc
- Around line 220:
Unknown directive: =sql
- Around line 228:
Unknown directive: =name
- Around line 230:
Unknown directive: =desc
- Around line 232:
Unknown directive: =sql
- Around line 239:
Unknown directive: =name
- Around line 241:
Unknown directive: =desc
- Around line 243:
Unknown directive: =sql
- Around line 250:
Unknown directive: =name
- Around line 252:
Unknown directive: =desc
- Around line 254:
Unknown directive: =sql
- Around line 262:
Unknown directive: =name
- Around line 264:
Unknown directive: =desc
- Around line 266:
Unknown directive: =sql
- Around line 274:
Unknown directive: =name
- Around line 276:
Unknown directive: =desc
- Around line 278:
Unknown directive: =sql
- Around line 286:
Unknown directive: =name
- Around line 288:
Unknown directive: =desc
- Around line 290:
Unknown directive: =param
- Around line 294:
Unknown directive: =sql
- Around line 307:
Unknown directive: =name
- Around line 309:
Unknown directive: =desc
- Around line 311:
Unknown directive: =sql
- Around line 319:
Unknown directive: =name
- Around line 321:
Unknown directive: =desc
- Around line 323:
Unknown directive: =sql
- Around line 340:
Unknown directive: =name
- Around line 342:
Unknown directive: =desc
- Around line 344:
Unknown directive: =sql
- Around line 352:
Unknown directive: =name
- Around line 354:
Unknown directive: =desc
- Around line 356:
Unknown directive: =sql
- Around line 366:
Unknown directive: =name
- Around line 368:
Unknown directive: =desc
- Around line 370:
Unknown directive: =sql
- Around line 381:
Unknown directive: =name
- Around line 383:
Unknown directive: =desc
- Around line 385:
Unknown directive: =sql
- Around line 395:
Unknown directive: =name
- Around line 397:
Unknown directive: =desc
- Around line 399:
Unknown directive: =sql
- Around line 408:
Unknown directive: =name
- Around line 410:
Unknown directive: =desc
- Around line 412:
Unknown directive: =sql
- Around line 420:
Unknown directive: =name
- Around line 422:
Unknown directive: =desc
- Around line 424:
Unknown directive: =sql
- Around line 432:
Unknown directive: =name
- Around line 434:
Unknown directive: =desc
- Around line 436:
Unknown directive: =sql
- Around line 452:
Unknown directive: =name
- Around line 454:
Unknown directive: =desc
- Around line 456:
Unknown directive: =sql
- Around line 465:
Unknown directive: =name
- Around line 467:
Unknown directive: =desc
- Around line 469:
Unknown directive: =sql