Skip to content

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