-
-
19 Dec 2021 02:26:57 UTC
- Distribution: Yancy
- Module version: 1.088
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (17)
- Testers (48 / 0 / 2)
- Kwalitee
Bus factor: 1- 77.17% Coverage
- License: perl_5
- Perl: v5.16.0
- Activity
24 month- Tools
- Download (1.34MB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 11 contributors-
Boris Däppen
-
Ed J
-
Erik Johansen
-
flash548
-
Josh Rabinowitz
-
Mohammad S Anwar
-
Pavel Serikov
-
Rajesh Mallah
-
Roy Storey
-
William Lindley
-
Wojtek Bażant
NAME
Yancy::Backend::Pg - A backend for Postgres using Mojo::Pg
VERSION
version 1.088
SYNOPSIS
### URL string use Mojolicious::Lite; plugin Yancy => { backend => 'pg://user:pass@localhost/mydb', read_schema => 1, }; ### Mojo::Pg object use Mojolicious::Lite; use Mojo::Pg; plugin Yancy => { backend => { Pg => Mojo::Pg->new( 'postgres:///myapp' ) }, read_schema => 1, }; ### Hashref use Mojolicious::Lite; plugin Yancy => { backend => { Pg => { dsn => 'dbi:Pg:dbname', username => 'fry', password => 'b3nd3r1sgr34t', }, }, read_schema => 1, };
DESCRIPTION
This Yancy backend allows you to connect to a Postgres database to manage the data inside. This backend uses Mojo::Pg to connect to Postgres.
See Yancy::Backend for the methods this backend has and their return values.
Backend URL
The URL for this backend takes the form
pg://<user>:<pass>@<host>:<port>/<db>
.Some examples:
# Just a DB pg:///mydb # User+DB (server on localhost:5432) pg://user@/mydb # User+Pass Host and DB pg://user:pass@example.com/mydb
Schema Names
The schema names for this backend are the names of the tables in the database.
So, if you have the following schema:
CREATE TABLE people ( id SERIAL, name VARCHAR NOT NULL, email VARCHAR NOT NULL ); CREATE TABLE business ( id SERIAL, name VARCHAR NOT NULL, email VARCHAR NULL );
You could map that to the following schema:
{ backend => 'pg://user@/mydb', schema => { People => { required => [ 'name', 'email' ], properties => { id => { type => 'integer', readOnly => 1, }, name => { type => 'string' }, email => { type => 'string' }, }, }, Business => { required => [ 'name' ], properties => { id => { type => 'integer', readOnly => 1, }, name => { type => 'string' }, email => { type => 'string' }, }, }, }, }
Ignored Tables
By default, this backend will ignore some tables when using
read_schema
: Tables used by Mojo::Pg::Migrations, DBIx::Class::Schema::Versioned (in case we're co-habitating with a DBIx::Class schema), and all the tables used by the Minion::Backend::Pg Minion backend.SEE ALSO
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Yancy, copy and paste the appropriate command in to your terminal.
cpanm Yancy
perl -MCPAN -e shell install Yancy
For more information on module installation, please visit the detailed CPAN module installation guide.