OData-QueryParams-DBIC

parse OData style query params and provide info for DBIC queries.


License
Artistic-2.0

Documentation

Build Status Kwalitee status GitHub issues

NAME

OData::QueryParams::DBIC - parse OData style query params and provide info for DBIC queries.

VERSION

version 0.01

SYNOPSIS

use OData::QueryParams::DBIC;

my $query_string = 'orderby=username asc, userid';
my $opts         = params_to_dbic( $query_string );

# { order_by => [ {-asc => 'username'}, {-asc => 'userid'} ] }
# can be used in
# $schema->resultset('users')->search( undef, $opts );

DESCRIPTION

The OData protocol defines the behaviour of Query String Options. This module aims to help you when you want to use the OData query string options with an application that uses DBIx::Class.

It parses the query parameters and creates a hash of DBIx::Class options that can be used in the search method.

EXPORTED FUNCTION

params_to_dbic

This function returns a hash reference of options that can be used as options for the search method in DBIx::Class.

use OData::QueryParams::DBIC;

my $query_string = 'orderby=username asc, userid';
my $opts         = params_to_dbic( $query_string );

Development

The distribution is contained in a Git repository, so simply clone the repository

$ git clone git://github.com/reneeb/OData-QueryParams-DBIC.git

and change into the newly-created directory.

$ cd OData-QueryParams-DBIC

The project uses Dist::Zilla to build the distribution, hence this will need to be installed before continuing:

$ cpanm Dist::Zilla

To install the required prequisite packages, run the following set of commands:

$ dzil authordeps --missing | cpanm
$ dzil listdeps --author --missing | cpanm

The distribution can be tested like so:

$ dzil test

To run the full set of tests (including author and release-process tests), add the --author and --release options:

$ dzil test --author --release

AUTHOR

Renee Baecker <reneeb@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)