DBIx-Quick

 view release on metacpan or  search on metacpan

lib/DBIx/Quick.pm  view on Meta::CPAN


 my @transactions = @{$dao->search(
	# SQL::Abstract::More where syntax using field names instead of columns
 	amnt => { '>', 10000 },
 	tax  =>	21,
 )}

Searchs ::Instance Objects in the table using L<SQL::Abstract::More> where syntax but replacing the column names by field names.

=head2 free_search

 my @transactions = @{$dao->free_search(
 	-join => [
 		'users.id=transactions.id_user users',
 	],
        -where => {
 		'users.surname' => {-like => 'Gar%'},
 	},
 )};

Searchs ::Instance Objects in the table using all the syntax of L<SQL::Abstract::More> select, columns are the real columns not fields.

-columns and -from are not allowed to be used. -from should be substituted by -join and -columns is not needed.

=head2 insert

 $dao->insert(MyApp::DAO::Users::Instance->new(username => 'ent'));

Inserts a row in the table, doesn't return the inserted field. You can use UUIDs or other known unique attributes of the table to search for
the inserted object.

=head2 update

 $user->username('X');
 $user->surname('González');
 $dao->update($user, 'username', 'surname');

Takes an instance and a list of the fields that should be updated in db with the instance data for that row, updates them and doesn't have a
meaningful return. Searches the object to update by the primary key.

=head2 delete

 $dao->delete($user);

Vanishes the instance of the database. Searches by the primary key.

=head1 INSTANCE SUBS

=head2 fetch_again

 $user = $user->fetch_again;

Get remote updates the ::Instance object may have.

=head2 dbh

 $user->dbh($dbh);

Sets a database to be used in the constructor of the corresponding DAO while doing fetch_again.

=head1 BUGS AND LIMITATIONS

Every DAO/Instance must be associated directly with a table, if you need something extra, the good old and reliable L<SQL::Abstract::More> is 
enough to you.

Errors must be improved to allow users to debug easier faulty code.

API is not stable since this program is so early in its development that I do not know if incorrect assumptions or bad design is hiding here.

No many to many easy wrapper, use free_search, I could not come up with something that would be better than directly creating your own
queries with free_search.

=head1 AUTHOR

SERGIOXZ - Sergio Iglesias

=head1 CONTRIBUTORS

SERGIOXZ - Sergio Iglesias

=head1 COPYRIGHT

Copyright © Sergio Iglesias (2025)

=head1 LICENSE

This library is free software and may be distributed under the same terms
as perl itself. See L<https://dev.perl.org/licenses/>.

=cut



( run in 0.778 second using v1.01-cache-2.11-cpan-39bf76dae61 )