Yancy::Model::Schema - Interface to a single schema
version 1.072
my $schema = $app->model->schema( 'foo' ); my $id = $schema->create( $data ); my $item = $schema->get( $id ); my $count = $schema->delete( $id ); my $count = $schema->delete( $where ); my $count = $schema->set( $id, $data ); my $count = $schema->set( $where, $data ); my $res = $schema->list( $where, $opts ); for my $item ( @{ $res->{items} } ) { ... }
NOTE: This module is experimental and its API may change before Yancy v2!
For information on how to extend this module to add your own schema and item methods, see Yancy::Guides::Model.
The Yancy::Model object that created this schema object.
The name of the schema.
The JSON Schema for this schema.
The ID field for this schema. Either a single string, or an arrayref of strings (for composite keys).
Turn a hashref of row data into a Yancy::Model::Item object using "find_class" in Yancy::Model to find the correct class.
Get an item by its ID. Returns a Yancy::Model::Item object.
List items. Returns a hash reference with items and total keys. The items is an array ref of Yancy::Model::Item objects. total is the total number of items that would be returned without any offset or limit options.
items
total
offset
limit
Create a new item. Returns the ID of the created item.
Set the given fields in an item. See also "set" in Yancy::Model::Item.
Delete an item. See also "delete" in Yancy::Model::Item.
Yancy::Guides::Model, Yancy::Model
Doug Bell <preaction@cpan.org>
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.
To install Yancy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Yancy
CPAN shell
perl -MCPAN -e shell install Yancy
For more information on module installation, please visit the detailed CPAN module installation guide.