Closed morenol closed 3 years ago
What do you think about this? @emmanuelantony2000
Maybe I can start with the typsense-derive crate, and then we can think in how we can integrate that with the client.
I think the collection
API should be something like fn collection<T: Collection>(&self) -> CollectionClient<T>
, or the API will be hard to use in my opinion.
What do you think about this? @emmanuelantony2000
Maybe I can start with the typsense-derive crate, and then we can think in how we can integrate that with the client.
That sounds good!
In the other libraries, they do something like:
client.collections.create(schema) client.collections['companies'].delete() client.collections['companies'].retrieve() client.collections.retrieve()
It might be possible in Rust, using Index
and/or IndexMut
traits.
In the other libraries, they do something like:
client.collections.create(schema) client.collections['companies'].delete() client.collections['companies'].retrieve() client.collections.retrieve()
It might be possible in Rust with
Index
orIndexMut
traits. However, because this will force users to provide collection name and type separately, e.g.client.collection["companies"].retrieve::<Company>()
. We will lose some power of static checking. With thecollection
, we can force users to tie collection name and their type together to prevent a user from using an unrelated type with a collection.
Description
We need the Collections API, here is my proposal for this. Add your comments in this issue to talk about the design of the Collections API
Specification
I think that we can implement a macro for this.
Example
That macro should implement the schema needed to create a Collection.
Specifically, a trait like this one:
Where CollectionSchema should be compatible with the things that typesense expects, i.e:
Client Interface
Features needed:
I am still not sure how should be the interface of the library client to create, delete, retrieve or list the collections.
In the other libraries, they do something like:
Maybe something like this:
Where the CollectionClient struct has retrieve, delete and create implementations.