NAME
Yancy::Model::Schema - Interface to a single schema
VERSION
version 1.075
SYNOPSIS
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} } ) { ... }
DESCRIPTION
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.
ATTRIBUTES
model
The Yancy::Model object that created this schema object.
name
The name of the schema.
METHODS
info
The JSON Schema for this schema.
id_field
The ID field for this schema. Either a single string, or an arrayref of strings (for composite keys).
build_item
Turn a hashref of row data into a Yancy::Model::Item object using "find_class" in Yancy::Model to find the correct class.
get
Get an item by its ID. Returns a Yancy::Model::Item object.
list
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.
create
Create a new item. Returns the ID of the created item.
set
Set the given fields in an item. See also "set" in Yancy::Model::Item.
delete
Delete an item. See also "delete" in Yancy::Model::Item.
SEE ALSO
Yancy::Guides::Model, Yancy::Model
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.