TypeScript client@0.27.0 added support for the totalCount field on search responses (PR#1232).
With this change, the return type of search calls becomes an object in order to encompass the additional totalCount field alongside the matching records.
Response template from search calls:
{
"records": [
{
...
}
],
"totalCount": 10
}
Prior to the addition of this field, the API would return records directly.
Below is an example for adjusting the return type from the search endpoint in order to handle this change in your code when updating the SDK to version 0.27 or later:
From:
posts = await xata.db.Posts.search(search, { fuzziness: 2 });
to:
const { records } = await xata.db.Posts.search(search, { fuzziness: 2 });
posts = records;
//or
response = await xata.db.Posts.search(search, { fuzziness: 2 });
posts = response.records
number = response.totalCount
Note that all documentation references in https://docs.xata.io have been updated accordingly.
Comments
0 comments
Please sign in to leave a comment.