Our services are in categories, how can i query services by category?
Currently i get all services in one query, like so:
wixData . query ( “Bookings/Services” )
. find ()
. then ( ( results ) => {
$w ( “#serviceRepeater ” ). data = results.items ;
} );
I would like to perform individual queries to fetch only certain services in select categories, is this possible?
I tried .contains(‘category’, ‘my category name’); (also tried “categories”) but can’t seem to find how to do it.
When the results of all (with no filter) come back is category available? What do you see in the response?
Here are the collection fields i"m seeing: Bookings/Services collection
I wanted to query by service category and not the whole collection i.e i’d like to be able to do wixdata.query(‘services/myCategory’) …
That code above was just one attempt in trying to get my services by category. Obviously category is not a field in that collection/db…!
@sonicswapstu Sorry perhaps I’m confused. You can’t query a collection for something that doesn’t exist in the collection. I will get back to you about whether or not there is an API specific to categories.
@sonicswapstu Okay, got a quick response from the Bookings team. The way to access categories is through the getServiceAvailability API
When you run that you should see category name and ID of the service. Take a look and see if that will work
@amandam no that’s not what I’m looking for at all, thanks though.
That will get available slots for a service! Not even close
I simply want to fetch the services by category. I.e. get all services in category X.
I have similar question, any update on this?
https://support.wix.com/en/article/wix-bookings-schema-for-wix-search does a query on Bookings\services collection and returns category, but wixdata does not, can you explain?
Any update on the matter ?
amandam
February 14, 2023, 1:28pm
10
The items availabel for query are listed in the API docs. Categories is not a valid query in the bookings query builder
https://www.wix.com/velo/reference/wix-bookings-backend/bookings/querybookings