NAME

Search::Typesense::Collection - CRUD for Typesense collections

SYNOPSIS

my $typesense = Search::Typesense->new(
    host    => $host,
    api_key => $key,
);
my $collections = $typesense->collections;

The instantiation of this module is for internal use only. The methods are public.

get

if ( my $collections = $typesense->collections->get ) {
    # returns all collections
}
if ( my $collections = $typesense->collections->get($collection_name) ) {
    # returns collection matching $collection_name, if any
}

Response shown at https://typesense.org/docs/0.19.0/api/#retrieve-collection

my $results = $typesense->collections->search($collection_name, {q => 'London'});

The parameters for $query are defined at https://typesense.org/docs/0.19.0/api/#search-collection, as are the results.

Unlike other methods, if we find nothing, we still return the data structure (instead of undef instead of a 404 exception).

create

my $collection = $typesense->collections->create(\%definition);

Arguments and response as shown at https://typesense.org/docs/0.19.0/api/#create-collection

delete

my $response = $typesense->collections->delete($collection_name);

Response shown at https://typesense.org/docs/0.19.0/api/#drop-collection

delete_all

$typesense->collections->delete_all;

Deletes everything from Typesense. Use with caution!