Skip to content

Conversation

bidoubiwa
Copy link
Contributor

Related to this issue

  • GET /documents/:uid, GET /documents Add the possibility to reduce the body payload by using a query parameter called fields (previously called attributesToRetrieve), check the issue and the spec for the entire behavior.

Previous

function getDocument(docId: number)

new

function getDocument(docId: number, parameters: DocumentQuery)

usage

index.getDocument(1, { fields: ['title'] })

@bidoubiwa bidoubiwa added the enhancement New feature or request label Jul 6, 2022
@bidoubiwa bidoubiwa changed the title Add fields parameter to getDocument route Add fields parameter to getDocument route for v0.28.0 Jul 6, 2022
@bidoubiwa bidoubiwa requested review from brunoocasali and mdubus July 6, 2022 13:44
Comment on lines +357 to +358
if (Array.isArray(parameters?.fields)) {
return parameters?.fields?.join(',')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you already checked for the null in the if condition, typescript understand that in the line 358 it could be just parameters.fields.join(',') ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript understands it but then it is compiled in javascript, unfortunately, typescript does not add type checking!

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question raised above! But is approved anyway 🎉

@bidoubiwa bidoubiwa merged commit c4fc383 into bump-meilisearch-v0.28.0 Jul 6, 2022
@bidoubiwa bidoubiwa deleted the add_parameters_on_get_one_document_v0.28.0 branch July 6, 2022 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants