Skip to content

Hotfix: load the client if collection array is empty and allow to use everything dynamically #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EfrosIonelu
Copy link

  • load the client if collection array is empty and allow to use everything dynamically

- load the client if collection array is empty and allow to use everything dynamically
@npotier
Copy link
Member

npotier commented Feb 18, 2025

Hello @EfrosIonelu by curiosity, why would you need to load the config if no collections are defined ?

@EfrosIonelu
Copy link
Author

Hi, sure,
there is my example:
I added current library but i do not have any entity to typesense collection representation,
Instead i need to migrate to typesense dynamic collections that do not have model representation,

The idea is to have access to TypesenseClient, if there are not collection and add collection definition dynamically

...
public function __construct(
    private readonly TypesenseClient  $typesenseClient,
...
if ($this->typesenseClient->getCollections()['example']->exists()) {
    $this->typesenseClient->getCollections()['example']->delete();
}
....
$this->typesenseClient->getCollections()->create([
            'name' => 'example',
            'enable_nested_fields' => true,
            'fields' => [
                ....
             ]       
....
$this->typesenseClient->getCollections()['example']->documents->upsert($data);
....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants