MongoDBx::Tiny::Attributes - offering field attributes
package My::Data::Foo; use MongoDBx::Tiny::Document; COLLECTION_NAME 'foo'; ESSENTIAL q/code/; FIELD 'code', INT, LENGTH(10), DEFAULT('0'), REQUIRED; FIELD 'name', STR, LENGTH(30), DEFAULT('noname'); # you can also define customized one. FIELD 'some', &SOME_ATTRIBUTE; sub SOME_ATTRIBUTE { name => 'SOME_ATTRIBUTE', callback => sub { my $target = shift; return MongoDBx::Tiny::Attributes::OK; }, }
callback = sub { my $target = shift; my $tiny = shift; my $opt = shift; # state => 'insert|update' return FAIL, { message => 'error' }; return OK, { target => $target }; # override target if you want }
LENGTH(255)
ENUM('on','off')
REGEX('\d+')
DEFAULT("foo") DEFAULT([])
DEFAULT(NOW('Asia/Tokyo')
Naoto ISHIKAWA, <toona at seesaa.co.jp>
<toona at seesaa.co.jp>
Kouji Tominaga, <tominaga at seesaa.co.jp>
<tominaga at seesaa.co.jp>
Copyright 2013 Naoto ISHIKAWA.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install MongoDBx::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MongoDBx::Tiny
CPAN shell
perl -MCPAN -e shell install MongoDBx::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.