How do I filter HubDb table rows using getTableRows() method? There's no option to add the sorting that's mentioned in the reference.
ERSBrad opened this issue · comments
Here's what I'm using:
$tableRows = $this->hubspotClient->cms()->hubdb()->rowsApi()->getTableRows($tableIdOrName);
In the HubDB API reference, it says the following:
Row results can be filtered and sorted. Filtering and sorting options will be sent as query parameters to the API request. For example, by adding the query parameters column1__gt=5&sort=-column1
, API returns the rows with values for column column1 greater than 5 and in the descending order of column1 values.
When you look at the source for getTableRows, there's nothing that lets me do what it says in the reference though.
public function getTableRows($table_id_or_name, $sort = null, $after = null, $limit = null, $properties = null)
;
What method should I be using to filter the rows returned? I don't won't to pull them all because it's going to be a huge table I'm grabbing the information from.
On a not so important side note:
With HubDb, can I make a column only accept unique identifiers?
HI @ERSBrad .
Filters for HubDB API are not supported in the SDK.
But you can get it by apiRequest method
Workable example:
$client = Factory::createwithAccessToken('YOUR_ACCESS_TOKEN');
$response = $client->apiRequest([
'path' => '/cms/v3/hubdb/tables/tableId/rows',
'qs' => ['name__contains' => 'Rice'],
]);
var_dump($response->getBody()->getContents());
Unfortunately I have no information about a column that accepts a unique ID.
You may ask HubSpot support about that.