NAME
DBIx::QuickORM::Manual::DBIxClass - Concept map from DBIx::Class to DBIx::QuickORM.
DESCRIPTION
If you are coming from DBIx::Class, this page maps its concepts to their DBIx::QuickORM equivalents so you can find the familiar thing quickly. It is a concept guide, not a migration tool, and the mapping is approximate - some things differ in important ways, called out under "NOTABLE DIFFERENCES".
QUICK REFERENCE
DBIx::Class DBIx::QuickORM
------------------------------ ----------------------------------------
Schema (class) an ORM defined with the DSL, or quick()
$schema = ...->connect(...) $orm = orm('name'); / DBIx::QuickORM->quick(...)
$schema->storage DBIx::QuickORM::Connection
ResultSource / Result class DBIx::QuickORM::Schema::Table (a "source")
ResultSet DBIx::QuickORM::Handle (a query/handle)
Result / Row object DBIx::QuickORM::Row
$rs->search(\%cond) $con->handle($table, \%where) / ->where(...)
$rs->find($id) $con->by_id($table => $id)
$rs->create(\%data) $con->insert($table => \%data)
$rs->all ->all
$rs->next (iterator) ->iterator then ->next
$rs->first / ->single ->first / ->one
$rs->count ->count
$row->update(\%data) / ->delete $row->update(\%data) / ->delete
has_many / belongs_to / has_one a link (foreign key)
$row->related_resultset / rel $row->follow($link) / $row->obtain($link)
prefetch / join $handle->join(...) (see Relations)
InflateColumn::* a DBIx::QuickORM::Role::Type class
$schema->txn_do(sub {...}) $con->txn(sub {...})
DBIx::Class::Schema::Loader autofill (automatic schema)
CORE OBJECTS
- ResultSet -> Handle
-
A DBIx::QuickORM::Handle is the closest analog to a
ResultSet: a query object you refine and then execute. Like aResultSet, refining a handle (where,order_by,limit, ...) returns a new handle rather than mutating it, so handles compose the same way ResultSets chain. See DBIx::QuickORM::Manual::Querying. - Result / Row -> Row
-
A DBIx::QuickORM::Row is the per-row object, like a DBIx::Class
Result. Read fields with$row->field('name');save/update/delete/refresh/discardbehave as you would expect. - ResultSource -> source (table/view/join/literal)
-
DBIx::Class's
ResultSourcecorresponds to a "source": usually a DBIx::QuickORM::Schema::Table (or a view, join, or literal SQL). A source is what a handle queries against. - Schema -> ORM
-
A DBIx::Class
Schemaclass maps to an ORM defined with the DBIx::QuickORM DSL (or built on the fly withDBIx::QuickORM->quick). See DBIx::QuickORM::Manual::Schema. - $schema->storage -> Connection
-
The live database connection is a DBIx::QuickORM::Connection, where transactions are controlled and handles are made. See DBIx::QuickORM::Manual::Connections.
QUERYING
$rs->search(\%cond, \%attrs) becomes a handle plus refinements:
# DBIx::Class
my $rs = $schema->resultset('People')->search({surname => 'smith'}, {order_by => 'first_name'});
# DBIx::QuickORM
my $h = $con->handle(people => {surname => 'smith'})->order_by('first_name');
Common methods map directly: find -> by_id, create -> insert, all -> all, count -> count, first/single -> first/one. For row-at-a-time iteration use an iterator:
my $it = $h->iterator;
while (my $row = $it->next) { ... }
See DBIx::QuickORM::Manual::Querying for the full handle API.
RELATIONSHIPS
DBIx::Class relationship declarations (has_many, belongs_to, might_have, has_one) map to a single concept: a link (a foreign-key relationship). At runtime you follow a link instead of calling a named relationship accessor:
$row->follow($link)-
Returns a handle for the related rows (like
$row->search_related/related_resultset>). $row->obtain($link)-
Returns the single related row (for a unique link), like following a
belongs_to/has_one.
With autorow, named accessors are generated for links (singular for unique links, plural otherwise), which is closer to DBIx::Class's named relationship accessors. prefetch/join-based queries map to joins on a handle. See DBIx::QuickORM::Manual::Relations.
RESULT CLASSES
In DBIx::Class you write a Result class per table. In DBIx::QuickORM you can similarly define each table in its own file (and add custom row methods), or let autorow generate row classes for you. See DBIx::QuickORM::Manual::Schema. Custom inflation/deflation that DBIx::Class does with InflateColumn::* components is handled by type classes; see DBIx::QuickORM::Manual::Types.
CONNECTING AND LOADING SCHEMA
Schema->connect(@info) maps to fetching a configured ORM and using its connection (orm('name') then ->connection/->handle), or to DBIx::QuickORM->quick(...) when you just want a connection from a DSN. See DBIx::QuickORM::Manual::QuickStart and DBIx::QuickORM::Manual::Connections.
DBIx::Class::Schema::Loader (generating a schema from an existing database) corresponds to autofill, except it happens at run time: DBIx::QuickORM introspects the live database every connection rather than generating Result classes ahead of time. See DBIx::QuickORM::Manual::Schema.
TRANSACTIONS
$schema->txn_do(sub {...}) and txn_scope_guard map to $con->txn(sub {...}); nested calls become savepoints. See DBIx::QuickORM::Manual::Transactions.
NOTABLE DIFFERENCES
- The database is canonical.
-
DBIx::QuickORM introspects table and column metadata from the live database; user-provided schema fills gaps and wins on conflict. There is no "deploy" step that creates tables from your classes the way DBIx::Class does.
- Dialects, not just storage drivers.
-
Database-flavor behavior lives in a dialect (SQLite, PostgreSQL, MySQL and its variants). See DBIx::QuickORM::Manual::Concepts.
- Row identity / caching is built in.
-
Each connection keeps at most one in-memory row object per primary key. See DBIx::QuickORM::Manual::Caching.
- Async, aside, and forked queries.
-
Handles can run queries asynchronously, on a side connection, or in a forked child. See DBIx::QuickORM::Manual::Async.
SOURCE
The source code repository for DBIx-QuickORM can be found at https://github.com/exodist/DBIx-QuickORM/.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.