Giter Site home page Giter Site logo

dbix-class-weight's Introduction

NAME

DBIx::Class::Weight

DESCRIPTION

Provides methods for easily managing weighted rows.

Component requires you to specify a weight column, and optionally a subclass column

The weight column should contain unique integers.

If a subclass column is specificed, the weight column is assumed to have one unique group of integers for each subclass column.

SYNOPSIS

In your Result class:

__PACKAGE__->load_components(qw/ Weight /);
__PACKAGE__->add_columns(
  weight => { data_type => 'integer' },
  weight_group => { data_type => 'integer' }, # optional
);
__PACKAGE__->weight_column('weight');
__PACKAGE__->weight_group_column('category'); # optional

Using the component

# When a row is created, weight column is automatically
# set to the current highest weight + 1, with L<next_weight>
$row = $schema->resultset('Thing')->create(\%thing);

# The weight values for the set can be easily adjusted
$row->weight_up;
$row->weight_down;

@rows = $rs->search(undef, {order_by => 'weight'});

METHODS

insert

Hook into insert, set the value of weight column to next available value

next_weight

Get the next unused weight value

weight_up

Move this record up in weight order

weight_down

Move this record down in weight order

COPYRIGHT AND LICENSE

This module is free software under the perl5 license

(c) 2019 Mitch Jackson [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.