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, enc => 'utf8');
my $sth = $dbh->prepare($pos->{'user'});
SEE ALSO
SQL definitions
For access methods
user
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.order_by, r.ts;
user roles
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
select count(*) from {% $schema %}refs where id1 = any(?) and id2 = ANY(?);
access action
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
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
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
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, order_by) 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;
namespace
select * from {% $schema %}namespaces where id=? or namespace = ?;
new namespace
insert into {% $schema %}namespaces (namespace, descr) 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 *;
тест
ыудусе * акщь тест!ж
81 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: =sql
- Around line 56:
Unknown directive: =name
- Around line 58:
Unknown directive: =desc
- Around line 60:
Unknown directive: =sql
- Around line 82:
Unknown directive: =name
- Around line 84:
Unknown directive: =desc
- Around line 86:
Unknown directive: =sql
- Around line 97:
Unknown directive: =name
- Around line 99:
Unknown directive: =desc
- Around line 101:
Unknown directive: =sql
- Around line 109:
Unknown directive: =name
- Around line 111:
Unknown directive: =desc
- Around line 113:
Unknown directive: =sql
- Around line 131:
Unknown directive: =name
- Around line 133:
Unknown directive: =desc
- Around line 135:
Unknown directive: =sql
- Around line 150:
Unknown directive: =name
- Around line 152:
Unknown directive: =desc
- Around line 154:
Unknown directive: =sql
- Around line 171:
Unknown directive: =name
- Around line 173:
Unknown directive: =desc
- Around line 175:
Unknown directive: =sql
- Around line 182:
Unknown directive: =name
- Around line 184:
Unknown directive: =desc
- Around line 186:
Unknown directive: =sql
- Around line 194:
Unknown directive: =name
- Around line 196:
Unknown directive: =desc
- Around line 198:
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 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 269:
Unknown directive: =name
- Around line 271:
Unknown directive: =desc
- Around line 273:
Unknown directive: =sql
- Around line 281:
Unknown directive: =name
- Around line 283:
Unknown directive: =desc
- Around line 285:
Unknown directive: =sql
- Around line 302:
Unknown directive: =name
- Around line 304:
Unknown directive: =desc
- Around line 306:
Unknown directive: =sql
- Around line 314:
Unknown directive: =name
- Around line 316:
Unknown directive: =desc
- Around line 318:
Unknown directive: =sql
- Around line 328:
Unknown directive: =name
- Around line 330:
Unknown directive: =desc
- Around line 332:
Unknown directive: =sql
- Around line 343:
Unknown directive: =name
- Around line 345:
Unknown directive: =desc
- Around line 347:
Unknown directive: =sql
- Around line 357:
Unknown directive: =name
- Around line 359:
Unknown directive: =desc
- Around line 361:
Unknown directive: =sql
- Around line 368:
Unknown directive: =name
- Around line 370:
Unknown directive: =desc
- Around line 372:
Unknown directive: =sql
- Around line 380:
Unknown directive: =name
- Around line 382:
Unknown directive: =desc
- Around line 384:
Unknown directive: =sql
- Around line 392:
Unknown directive: =name
- Around line 394:
Unknown directive: =desc
- Around line 396:
Unknown directive: =sql
- Around line 412:
Unknown directive: =name
- Around line 414:
Unknown directive: =desc
- Around line 416:
Unknown directive: =sql
- Around line 425:
Unknown directive: =name
- Around line 427:
Unknown directive: =desc
- Around line 429:
Unknown directive: =sql