meilisearch-go
meilisearch-go copied to clipboard
Add `updatedAt` and `createdAt` to `Index`
When manipulating indexes (get/create/update), the MeiliSearch server returns the following information related to the index:
-
uid
: the uid of the index -
primaryKey
: the primary key of the index -
updateAt
: when the index has been updated -
createdAt
: when the index has been created
This SDK, when manipulating indexes (get/create/update) returns an instance of Index
which already contains the primaryKey
and uid
members.
It means we can currently get the primaryKey
and the uid
, but not updatedAt
and createdAt
.
TODO:
- [x] Add
updatedAt
andcreatedAt
member in theIndex
class/struct (depending on the language). - [ ] Update the variable in the code where
primaryKey
is already updated. Ex: when getting the index withgetIndex()
- [ ] Add tests
⚠️ This issue is generated, it means primaryKey
, updatedAt
, and createdAt
might be named differently in this package (ex: primary_key
instead). Keep the already existing way of naming in this package to stay idiomatic with the language and the repository.
Also, if you are a maintainer, feel free to add any clarification and instruction about this issue related to the specific languages of the repo.
Related to https://github.com/meilisearch/integration-guides/issues/121
Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue in the repo.
Can I please work on this?
Spoke too fast, looks like Index already have those properties
Hi @kashifsoofi, You're right the two fields already exist but It seems they aren't well updated and the tests are missing too.
@curquiza I'm looking to implement the 2nd todo but I don't understand what it means
func (i Index) FetchInfo() (resp *Index, err error) {
resp = newIndex(i.client, i.UID)
req := internalRequest{
endpoint: "/indexes/" + i.UID,
method: http.MethodGet,
withRequest: nil,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusOK},
functionName: "FetchInfo",
}
if err := i.client.executeRequest(req); err != nil {
return nil, err
}
i.PrimaryKey = resp.PrimaryKey //nolint:golint,staticcheck
return resp, nil
}
index
is passed as value instead of pointer, what's the point of i.PrimaryKey = resp.PrimaryKey
?
Hi @Azanul
@curquiza I'm looking to implement the 2nd todo but I don't understand what it means
The second todo explains that when you use the GetIndex()
method you pass through the FetchInfo()
method which uses an instance of the Index
in question but the data in the index must be updated at the same time
index is passed as value instead of pointer, what's the point of i.PrimaryKey = resp.PrimaryKey ?
This is what we have fixed by:
func (i *Index) FetchInfo() (resp *Index, err error) {
And also update the updateAt
and createdAt
Leaving this for someone else, don't want to hog all good first issues for myself.
Feel free to do whatever you like.
@tanbirali @ayesha-firdaus @rafiya2003
I would like to do this work
While @rafiya2003 completes task 2, @tanbirali @ayesha-firdaus you guys can look into adding tests if interested.
While @rafiya2003 completes task 2, @tanbirali @ayesha-firdaus you guys can look into adding tests if interested.
You can indeed add the missing tests to another PR, but as for the rest, each piece of code added must be accompanied by the corresponding tests.