Search...
queryServices( )
Developer Preview
Retrieves a list of up to 100 services, given the provided paging, filtering, and sorting.
Description
queryServices()
runs with these defaults, which you can override:
paging.limit
is100
.paging.offset
is0
.
Notes:
- Use UTC format when filtering with dates.
- Only 1 use of each filter in the same query is supported. If a filter is defined more than once in a query, only the first occurrence is processed.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
type | eq() ,ne() ,exists() ,in() ,hasSome() |
name | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
description | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
tagLine | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
hidden | eq() ,ne() ,exists() ,in() ,hasSome() |
category.id | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
category.name | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
form.id | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
payment.options.online | eq() ,ne() ,exists() ,in() ,hasSome() |
payment.options.inPerson | eq() ,ne() ,exists() ,in() ,hasSome() |
payment.options.pricingPlan | eq() ,ne() ,exists() ,in() ,hasSome() |
onlineBooking.enabled | eq() ,ne() ,exists() ,in() ,hasSome() |
locations.business.id | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
staffMemberIds | eq() ,ne() ,exists() ,in() ,hasSome() ,hasAll() |
supportedSlugs.name | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
mainSlug.name | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
Syntax
function queryServices(): ServicesQueryBuilder
queryServices Parameters
This function does not take any parameters.
Returns
Return Type:
Was this helpful?
Query services with default settings
Query services without any filters. The defaults are a limit
of 100, and an offset
of 0.
Copy Code
12import {services} from 'wix-bookings.v2';34async function queryServices() {5 const result = await services.queryServices().find()6 return result.items;7}89/* Promise resolves to:10 [11 {12 "type": "COURSE",13 "sortOrder": 5,14 "name": "Cat Hugging Training",15 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will train you to become the best cat hugger around.",16 "tagLine": "Get some purr therapy training with our cat hugging experts",17 "defaultCapacity": 30,18 "hidden": false,19 "category": {20 "name": "Our Services",21 "sortOrder": 0,22 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"23 },24 "payment": {25 "rateType": "FIXED",26 "fixed": {27 "price": {28 "value": "150",29 "currency": "USD"30 }31 },32 "options": {33 "online": true,34 "inPerson": false,35 "deposit": false,36 "pricingPlan": false37 },38 "pricingPlanIds": []39 },40 "onlineBooking": {41 "enabled": true42 },43 "locations": [44 {45 "type": "BUSINESS"46 }47 ],48 "bookingPolicy": {49 "revision": "1",50 "name": "Default policy",51 "customPolicyDescription": {52 "enabled": true,53 "description": ""54 },55 "default": true,56 "limitEarlyBookingPolicy": {57 "enabled": false,58 "earliestBookingInMinutes": 1008059 },60 "limitLateBookingPolicy": {61 "enabled": false,62 "latestBookingInMinutes": 144063 },64 "bookAfterStartPolicy": {65 "enabled": false66 },67 "cancellationPolicy": {68 "enabled": true,69 "limitLatestCancellation": false,70 "latestCancellationInMinutes": 144071 },72 "reschedulePolicy": {73 "enabled": true,74 "limitLatestReschedule": false,75 "latestRescheduleInMinutes": 144076 },77 "waitlistPolicy": {78 "enabled": false,79 "capacity": 10,80 "reservationTimeInMinutes": 1081 },82 "participantsPolicy": {83 "enabled": true,84 "maxParticipantsPerBooking": 185 },86 "resourcesPolicy": {87 "enabled": false,88 "autoAssignAllowed": false89 },90 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",91 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",92 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"93 },94 "schedule": {95 "_id": "326e4696-bef0-4e37-83ad-db33236f1106"96 },97 "staffMemberIds": [],98 "staffMembers": [],99 "resourceGroups": [],100 "serviceResources": [],101 "supportedSlugs": [102 {103 "name": "cat-hugging-training",104 "custom": false,105 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"106 }107 ],108 "mainSlug": {109 "name": "cat-hugging-training",110 "custom": false,111 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"112 },113 "urls": {114 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training",115 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training"116 },117 "revision": "1",118 "_id": "2e226dda-ba40-4565-b984-d7425a603e4c",119 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)",120 "_updatedDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"121 },122 {123 "type": "CLASS",124 "sortOrder": 4,125 "name": "Group Cat Hugging",126 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",127 "tagLine": "Get some purr therapy with our cat hugging service!",128 "defaultCapacity": 30,129 "hidden": false,130 "category": {131 "name": "Our Services",132 "sortOrder": 0,133 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"134 },135 "payment": {136 "rateType": "FIXED",137 "fixed": {138 "price": {139 "value": "25",140 "currency": "USD"141 },142 "deposit": {143 "value": "5",144 "currency": "USD"145 }146 },147 "options": {148 "online": true,149 "inPerson": false,150 "deposit": false,151 "pricingPlan": false152 },153 "pricingPlanIds": []154 },155 "onlineBooking": {156 "enabled": true157 },158 "locations": [159 {160 "type": "BUSINESS"161 }162 ],163 "bookingPolicy": {164 "revision": "1",165 "name": "Default policy",166 "customPolicyDescription": {167 "enabled": true,168 "description": ""169 },170 "default": true,171 "limitEarlyBookingPolicy": {172 "enabled": false,173 "earliestBookingInMinutes": 10080174 },175 "limitLateBookingPolicy": {176 "enabled": false,177 "latestBookingInMinutes": 1440178 },179 "bookAfterStartPolicy": {180 "enabled": false181 },182 "cancellationPolicy": {183 "enabled": true,184 "limitLatestCancellation": false,185 "latestCancellationInMinutes": 1440186 },187 "reschedulePolicy": {188 "enabled": true,189 "limitLatestReschedule": false,190 "latestRescheduleInMinutes": 1440191 },192 "waitlistPolicy": {193 "enabled": false,194 "capacity": 10,195 "reservationTimeInMinutes": 10196 },197 "participantsPolicy": {198 "enabled": true,199 "maxParticipantsPerBooking": 1200 },201 "resourcesPolicy": {202 "enabled": false,203 "autoAssignAllowed": false204 },205 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",206 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",207 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"208 },209 "schedule": {210 "_id": "81aa34a4-0cbc-4476-b8ec-62878024cd97"211 },212 "staffMemberIds": [],213 "staffMembers": [],214 "resourceGroups": [],215 "serviceResources": [],216 "supportedSlugs": [217 {218 "name": "group-cat-hugging-1",219 "custom": false,220 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"221 }222 ],223 "mainSlug": {224 "name": "group-cat-hugging-1",225 "custom": false,226 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"227 },228 "urls": {229 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/group-cat-hugging-1",230 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1",231 "calendarPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1"232 },233 "revision": "1",234 "_id": "fad1a29c-d06b-4ce7-ab80-98c54c4e0772",235 "_createdDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)",236 "_updatedDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)"237 }238 ]239 */240
Filter services by category ID
Copy Code
12import {services} from 'wix-bookings.v2';34/*5 * Sample categoryId value: '99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c'6 */7async function filterServicesByCategoryId(categoryId) {8 const result = await services.queryServices()9 .eq("category.id", categoryId)10 .find()1112 return result.items;13}1415/* Promise resolves to:16 [17 {18 "type": "COURSE",19 "sortOrder": 5,20 "name": "Cat Hugging Training",21 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will train you to become the best cat hugger around.",22 "tagLine": "Get some purr therapy training with our cat hugging experts",23 "defaultCapacity": 30,24 "hidden": false,25 "category": {26 "name": "Our Services",27 "sortOrder": 0,28 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"29 },30 "payment": {31 "rateType": "FIXED",32 "fixed": {33 "price": {34 "value": "150",35 "currency": "USD"36 }37 },38 "options": {39 "online": true,40 "inPerson": false,41 "deposit": false,42 "pricingPlan": false43 },44 "pricingPlanIds": []45 },46 "onlineBooking": {47 "enabled": true48 },49 "locations": [50 {51 "type": "BUSINESS"52 }53 ],54 "bookingPolicy": {55 "revision": "1",56 "name": "Default policy",57 "customPolicyDescription": {58 "enabled": true,59 "description": ""60 },61 "default": true,62 "limitEarlyBookingPolicy": {63 "enabled": false,64 "earliestBookingInMinutes": 1008065 },66 "limitLateBookingPolicy": {67 "enabled": false,68 "latestBookingInMinutes": 144069 },70 "bookAfterStartPolicy": {71 "enabled": false72 },73 "cancellationPolicy": {74 "enabled": true,75 "limitLatestCancellation": false,76 "latestCancellationInMinutes": 144077 },78 "reschedulePolicy": {79 "enabled": true,80 "limitLatestReschedule": false,81 "latestRescheduleInMinutes": 144082 },83 "waitlistPolicy": {84 "enabled": false,85 "capacity": 10,86 "reservationTimeInMinutes": 1087 },88 "participantsPolicy": {89 "enabled": true,90 "maxParticipantsPerBooking": 191 },92 "resourcesPolicy": {93 "enabled": false,94 "autoAssignAllowed": false95 },96 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",97 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",98 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"99 },100 "schedule": {101 "_id": "326e4696-bef0-4e37-83ad-db33236f1106"102 },103 "staffMemberIds": [],104 "staffMembers": [],105 "resourceGroups": [],106 "serviceResources": [],107 "supportedSlugs": [108 {109 "name": "cat-hugging-training",110 "custom": false,111 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"112 }113 ],114 "mainSlug": {115 "name": "cat-hugging-training",116 "custom": false,117 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"118 },119 "urls": {120 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training",121 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training"122 },123 "revision": "1",124 "_id": "2e226dda-ba40-4565-b984-d7425a603e4c",125 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)",126 "_updatedDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"127 },128 {129 "type": "CLASS",130 "sortOrder": 4,131 "name": "Group Cat Hugging",132 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",133 "tagLine": "Get some purr therapy with our cat hugging service!",134 "defaultCapacity": 30,135 "hidden": false,136 "category": {137 "name": "Our Services",138 "sortOrder": 0,139 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"140 },141 "payment": {142 "rateType": "FIXED",143 "fixed": {144 "price": {145 "value": "25",146 "currency": "USD"147 },148 "deposit": {149 "value": "5",150 "currency": "USD"151 }152 },153 "options": {154 "online": true,155 "inPerson": false,156 "deposit": false,157 "pricingPlan": false158 },159 "pricingPlanIds": []160 },161 "onlineBooking": {162 "enabled": true163 },164 "locations": [165 {166 "type": "BUSINESS"167 }168 ],169 "bookingPolicy": {170 "revision": "1",171 "name": "Default policy",172 "customPolicyDescription": {173 "enabled": true,174 "description": ""175 },176 "default": true,177 "limitEarlyBookingPolicy": {178 "enabled": false,179 "earliestBookingInMinutes": 10080180 },181 "limitLateBookingPolicy": {182 "enabled": false,183 "latestBookingInMinutes": 1440184 },185 "bookAfterStartPolicy": {186 "enabled": false187 },188 "cancellationPolicy": {189 "enabled": true,190 "limitLatestCancellation": false,191 "latestCancellationInMinutes": 1440192 },193 "reschedulePolicy": {194 "enabled": true,195 "limitLatestReschedule": false,196 "latestRescheduleInMinutes": 1440197 },198 "waitlistPolicy": {199 "enabled": false,200 "capacity": 10,201 "reservationTimeInMinutes": 10202 },203 "participantsPolicy": {204 "enabled": true,205 "maxParticipantsPerBooking": 1206 },207 "resourcesPolicy": {208 "enabled": false,209 "autoAssignAllowed": false210 },211 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",212 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",213 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"214 },215 "schedule": {216 "_id": "81aa34a4-0cbc-4476-b8ec-62878024cd97"217 },218 "staffMemberIds": [],219 "staffMembers": [],220 "resourceGroups": [],221 "serviceResources": [],222 "supportedSlugs": [223 {224 "name": "group-cat-hugging-1",225 "custom": false,226 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"227 }228 ],229 "mainSlug": {230 "name": "group-cat-hugging-1",231 "custom": false,232 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"233 },234 "urls": {235 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/group-cat-hugging-1",236 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1",237 "calendarPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1"238 },239 "revision": "1",240 "_id": "fad1a29c-d06b-4ce7-ab80-98c54c4e0772",241 "_createdDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)",242 "_updatedDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)"243 }244 ]245 */246
Sort services alphabetically by name
Copy Code
12import {services} from 'wix-bookings.v2';34async function getServicesSorted() {5 const result = await services.queryServices()6 .ascending("name")7 .find()89 return result.items;10}1112/* Promise resolves to:13 [14 {15 "type": "COURSE",16 "sortOrder": 5,17 "name": "Cat Hugging Training",18 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will train you to become the best cat hugger around.",19 "tagLine": "Get some purr therapy training with our cat hugging experts",20 "defaultCapacity": 30,21 "hidden": false,22 "category": {23 "name": "Our Services",24 "sortOrder": 0,25 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"26 },27 "payment": {28 "rateType": "FIXED",29 "fixed": {30 "price": {31 "value": "150",32 "currency": "USD"33 }34 },35 "options": {36 "online": true,37 "inPerson": false,38 "deposit": false,39 "pricingPlan": false40 },41 "pricingPlanIds": []42 },43 "onlineBooking": {44 "enabled": true45 },46 "locations": [47 {48 "type": "BUSINESS"49 }50 ],51 "bookingPolicy": {52 "revision": "1",53 "name": "Default policy",54 "customPolicyDescription": {55 "enabled": true,56 "description": ""57 },58 "default": true,59 "limitEarlyBookingPolicy": {60 "enabled": false,61 "earliestBookingInMinutes": 1008062 },63 "limitLateBookingPolicy": {64 "enabled": false,65 "latestBookingInMinutes": 144066 },67 "bookAfterStartPolicy": {68 "enabled": false69 },70 "cancellationPolicy": {71 "enabled": true,72 "limitLatestCancellation": false,73 "latestCancellationInMinutes": 144074 },75 "reschedulePolicy": {76 "enabled": true,77 "limitLatestReschedule": false,78 "latestRescheduleInMinutes": 144079 },80 "waitlistPolicy": {81 "enabled": false,82 "capacity": 10,83 "reservationTimeInMinutes": 1084 },85 "participantsPolicy": {86 "enabled": true,87 "maxParticipantsPerBooking": 188 },89 "resourcesPolicy": {90 "enabled": false,91 "autoAssignAllowed": false92 },93 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",94 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",95 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"96 },97 "schedule": {98 "_id": "326e4696-bef0-4e37-83ad-db33236f1106"99 },100 "staffMemberIds": [],101 "staffMembers": [],102 "resourceGroups": [],103 "serviceResources": [],104 "supportedSlugs": [105 {106 "name": "cat-hugging-training",107 "custom": false,108 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"109 }110 ],111 "mainSlug": {112 "name": "cat-hugging-training",113 "custom": false,114 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"115 },116 "urls": {117 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training",118 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training"119 },120 "revision": "1",121 "_id": "2e226dda-ba40-4565-b984-d7425a603e4c",122 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)",123 "_updatedDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"124 },125 {126 "type": "CLASS",127 "sortOrder": 4,128 "name": "Group Cat Hugging",129 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",130 "tagLine": "Get some purr therapy with our cat hugging service!",131 "defaultCapacity": 30,132 "hidden": false,133 "category": {134 "name": "Our Services",135 "sortOrder": 0,136 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"137 },138 "payment": {139 "rateType": "FIXED",140 "fixed": {141 "price": {142 "value": "25",143 "currency": "USD"144 },145 "deposit": {146 "value": "5",147 "currency": "USD"148 }149 },150 "options": {151 "online": true,152 "inPerson": false,153 "deposit": false,154 "pricingPlan": false155 },156 "pricingPlanIds": []157 },158 "onlineBooking": {159 "enabled": true160 },161 "locations": [162 {163 "type": "BUSINESS"164 }165 ],166 "bookingPolicy": {167 "revision": "1",168 "name": "Default policy",169 "customPolicyDescription": {170 "enabled": true,171 "description": ""172 },173 "default": true,174 "limitEarlyBookingPolicy": {175 "enabled": false,176 "earliestBookingInMinutes": 10080177 },178 "limitLateBookingPolicy": {179 "enabled": false,180 "latestBookingInMinutes": 1440181 },182 "bookAfterStartPolicy": {183 "enabled": false184 },185 "cancellationPolicy": {186 "enabled": true,187 "limitLatestCancellation": false,188 "latestCancellationInMinutes": 1440189 },190 "reschedulePolicy": {191 "enabled": true,192 "limitLatestReschedule": false,193 "latestRescheduleInMinutes": 1440194 },195 "waitlistPolicy": {196 "enabled": false,197 "capacity": 10,198 "reservationTimeInMinutes": 10199 },200 "participantsPolicy": {201 "enabled": true,202 "maxParticipantsPerBooking": 1203 },204 "resourcesPolicy": {205 "enabled": false,206 "autoAssignAllowed": false207 },208 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",209 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",210 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"211 },212 "schedule": {213 "_id": "81aa34a4-0cbc-4476-b8ec-62878024cd97"214 },215 "staffMemberIds": [],216 "staffMembers": [],217 "resourceGroups": [],218 "serviceResources": [],219 "supportedSlugs": [220 {221 "name": "group-cat-hugging-1",222 "custom": false,223 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"224 }225 ],226 "mainSlug": {227 "name": "group-cat-hugging-1",228 "custom": false,229 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"230 },231 "urls": {232 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/group-cat-hugging-1",233 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1",234 "calendarPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1"235 },236 "revision": "1",237 "_id": "fad1a29c-d06b-4ce7-ab80-98c54c4e0772",238 "_createdDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)",239 "_updatedDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)"240 }241 ]242 */243
Filter services by
mainSlug.name
Using the path
from the url
, filter and retrieve the relevant service.
Copy Code
12import {path} from 'wix-location';3import {services} from 'wix-bookings.v2';45export async function getServiceFromPath() {6 const [serviceNameInUrl] = path;7 const result = await services.queryServices()8 .eq("mainSlug.name", serviceNameInUrl)9 .limit(1)10 .find();1112 return result.items[0];13}1415/* Promise resolves to:16 [17 {18 "type": "COURSE",19 "sortOrder": 5,20 "name": "Cat Hugging Training",21 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will train you to become the best cat hugger around.",22 "tagLine": "Get some purr therapy training with our cat hugging experts",23 "defaultCapacity": 30,24 "hidden": false,25 "category": {26 "name": "Our Services",27 "sortOrder": 0,28 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"29 },30 "payment": {31 "rateType": "FIXED",32 "fixed": {33 "price": {34 "value": "150",35 "currency": "USD"36 }37 },38 "options": {39 "online": true,40 "inPerson": false,41 "deposit": false,42 "pricingPlan": false43 },44 "pricingPlanIds": []45 },46 "onlineBooking": {47 "enabled": true48 },49 "locations": [50 {51 "type": "BUSINESS"52 }53 ],54 "bookingPolicy": {55 "revision": "1",56 "name": "Default policy",57 "customPolicyDescription": {58 "enabled": true,59 "description": ""60 },61 "default": true,62 "limitEarlyBookingPolicy": {63 "enabled": false,64 "earliestBookingInMinutes": 1008065 },66 "limitLateBookingPolicy": {67 "enabled": false,68 "latestBookingInMinutes": 144069 },70 "bookAfterStartPolicy": {71 "enabled": false72 },73 "cancellationPolicy": {74 "enabled": true,75 "limitLatestCancellation": false,76 "latestCancellationInMinutes": 144077 },78 "reschedulePolicy": {79 "enabled": true,80 "limitLatestReschedule": false,81 "latestRescheduleInMinutes": 144082 },83 "waitlistPolicy": {84 "enabled": false,85 "capacity": 10,86 "reservationTimeInMinutes": 1087 },88 "participantsPolicy": {89 "enabled": true,90 "maxParticipantsPerBooking": 191 },92 "resourcesPolicy": {93 "enabled": false,94 "autoAssignAllowed": false95 },96 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",97 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",98 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"99 },100 "schedule": {101 "_id": "326e4696-bef0-4e37-83ad-db33236f1106"102 },103 "staffMemberIds": [],104 "staffMembers": [],105 "resourceGroups": [],106 "serviceResources": [],107 "supportedSlugs": [108 {109 "name": "cat-hugging-training",110 "custom": false,111 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"112 }113 ],114 "mainSlug": {115 "name": "cat-hugging-training",116 "custom": false,117 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"118 },119 "urls": {120 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training",121 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/service-page/cat-hugging-training"122 },123 "revision": "1",124 "_id": "2e226dda-ba40-4565-b984-d7425a603e4c",125 "_createdDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)",126 "_updatedDate": "Tue Jan 16 2024 17:29:55 GMT+0100 (Central European Standard Time)"127 },128 {129 "type": "CLASS",130 "sortOrder": 4,131 "name": "Group Cat Hugging",132 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",133 "tagLine": "Get some purr therapy with our cat hugging service!",134 "defaultCapacity": 30,135 "hidden": false,136 "category": {137 "name": "Our Services",138 "sortOrder": 0,139 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"140 },141 "payment": {142 "rateType": "FIXED",143 "fixed": {144 "price": {145 "value": "25",146 "currency": "USD"147 },148 "deposit": {149 "value": "5",150 "currency": "USD"151 }152 },153 "options": {154 "online": true,155 "inPerson": false,156 "deposit": false,157 "pricingPlan": false158 },159 "pricingPlanIds": []160 },161 "onlineBooking": {162 "enabled": true163 },164 "locations": [165 {166 "type": "BUSINESS"167 }168 ],169 "bookingPolicy": {170 "revision": "1",171 "name": "Default policy",172 "customPolicyDescription": {173 "enabled": true,174 "description": ""175 },176 "default": true,177 "limitEarlyBookingPolicy": {178 "enabled": false,179 "earliestBookingInMinutes": 10080180 },181 "limitLateBookingPolicy": {182 "enabled": false,183 "latestBookingInMinutes": 1440184 },185 "bookAfterStartPolicy": {186 "enabled": false187 },188 "cancellationPolicy": {189 "enabled": true,190 "limitLatestCancellation": false,191 "latestCancellationInMinutes": 1440192 },193 "reschedulePolicy": {194 "enabled": true,195 "limitLatestReschedule": false,196 "latestRescheduleInMinutes": 1440197 },198 "waitlistPolicy": {199 "enabled": false,200 "capacity": 10,201 "reservationTimeInMinutes": 10202 },203 "participantsPolicy": {204 "enabled": true,205 "maxParticipantsPerBooking": 1206 },207 "resourcesPolicy": {208 "enabled": false,209 "autoAssignAllowed": false210 },211 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",212 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",213 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"214 },215 "schedule": {216 "_id": "81aa34a4-0cbc-4476-b8ec-62878024cd97"217 },218 "staffMemberIds": [],219 "staffMembers": [],220 "resourceGroups": [],221 "serviceResources": [],222 "supportedSlugs": [223 {224 "name": "group-cat-hugging-1",225 "custom": false,226 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"227 }228 ],229 "mainSlug": {230 "name": "group-cat-hugging-1",231 "custom": false,232 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"233 },234 "urls": {235 "servicePage": "https://nitayr7.editorx.io/services-v2-test/service-page/group-cat-hugging-1",236 "bookingPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1",237 "calendarPage": "https://nitayr7.editorx.io/services-v2-test/booking-calendar/group-cat-hugging-1"238 },239 "revision": "1",240 "_id": "fad1a29c-d06b-4ce7-ab80-98c54c4e0772",241 "_createdDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)",242 "_updatedDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)"243 }244 ]245 */246