Mojolicious-Plugin-Fondation-Model-DBIx-Async

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


Each backend is a separate [DBIx::Class::Async::Schema](https://metacpan.org/pod/DBIx%3A%3AClass%3A%3AAsync%3A%3ASchema) with its own
[IO::Async::Loop::Mojo](https://metacpan.org/pod/IO%3A%3AAsync%3A%3ALoop%3A%3AMojo) and worker pool. Workers are forked lazily on
the first schema access and are automatically stopped on process exit.

## Model discovery

During `fondation_finalyze`, the plugin scans every loaded Fondation plugin
for a `models` key in their configuration. Models declared by dependency
plugins are merged, with the application configuration taking priority.
Each model is validated to have a resolvable backend.

## Source registration

The `DBIx` action ([Mojolicious::Plugin::Fondation::Model::DBIx::Async::Action::DBIx](https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AFondation%3A%3AModel%3A%3ADBIx%3A%3AAsync%3A%3AAction%3A%3ADBIx))
auto-discovers `Result` and `ResultSet` classes under each plugin's
`Schema::Result::*` and `Schema::ResultSet::*` namespaces and registers them
on the native schema class _before_ workers are forked.

## Shutdown

lib/Mojolicious/Plugin/Fondation/Model/DBIx/Async.pm  view on Meta::CPAN


Each backend is a separate L<DBIx::Class::Async::Schema> with its own
L<IO::Async::Loop::Mojo> and worker pool. Workers are forked lazily on
the first schema access and are automatically stopped on process exit.

=head2 Model discovery

During C<fondation_finalyze>, the plugin scans every loaded Fondation plugin
for a C<models> key in their configuration. Models declared by dependency
plugins are merged, with the application configuration taking priority.
Each model is validated to have a resolvable backend.

=head2 Source registration

The C<DBIx> action (L<Mojolicious::Plugin::Fondation::Model::DBIx::Async::Action::DBIx>)
auto-discovers C<Result> and C<ResultSet> classes under each plugin's
C<Schema::Result::*> and C<Schema::ResultSet::*> namespaces and registers them
on the native schema class I<before> workers are forked.

=head2 Shutdown

t/05-with.t  view on Meta::CPAN

# ─── 4. without with() — standard path still works ────────────────────────────

subtest 'model without with() still works' => sub {
    my $rows = $schema->await(
        $c->model('user')->all
    );
    is(scalar @$rows, 1, 'one user without with()');
    is($rows->[0]->name, 'Alice', 'correct user without with()');
};

# ─── 5. with() validates relationship exists ──────────────────────────────────

subtest 'with() dies on unknown relation' => sub {
    eval { $c->model('user')->with('nonexistent') };
    like($@, qr/No many_to_many or has_many relationship/,
        'dies on unknown relation');
};

# ─── 6. with() dies on belongs_to (single-accessor) ───────────────────────────

subtest 'with() dies on belongs_to relationship' => sub {



( run in 0.541 second using v1.01-cache-2.11-cpan-f4a522933cf )