Metaobject query filter

Live examples against test_booking_slot. Each card shows the filter call and what it returns.

Integer ranges

Split the day into windows using >= and < on a number field.

Morning

shop.metaobjects.test_booking_slot
  | query: "fields.slot_number:>=1 fields.slot_number:<13 fields.status:available"
,
    sort_key: "fields.slot_number"

No matching slots.

Afternoon

shop.metaobjects.test_booking_slot
  | query: "fields.slot_number:>=13 fields.status:available"
,
    sort_key: "fields.slot_number"

No matching slots.

Negation and "has a value"

A leading - negates a term. :* matches any value that's present.

Not available

shop.metaobjects.test_booking_slot
  | query: "-fields.status:available"

No stylist assigned

shop.metaobjects.test_booking_slot
  | query: "-fields.stylist:* fields.status:available"

Stylist assigned

shop.metaobjects.test_booking_slot
  | query: "fields.stylist:* fields.status:available"

Prefix match on text

A trailing * matches any value that starts with the prefix.

shop.metaobjects.test_booking_slot
  | query: "fields.status:avail*"

matching slots

No matching slots.

Sorting and reverse

Same query, three orderings. sort_key takes a field or a system attribute.

Highest slot number first

shop.metaobjects.test_booking_slot
  | query: "fields.status:available"
,
    sort_key: "fields.slot_number"
,
    reverse: true

No matching slots.

Recently edited

shop.metaobjects.test_booking_slot
  | query: "fields.status:available"
,
    sort_key: "updated_at"
,
    reverse: true

No matching slots.

By handle

shop.metaobjects.test_booking_slot
  | query: "fields.status:available"
,
    sort_key: "handle"

No matching slots.

Availability per stylist (counts only)

Two queries for each stylist, binding $s to the loop variable. Only .size is read.

shop.metaobjects.test_booking_slot
  | query: "fields.stylist:$s fields.status:available",
    s: s

shop.metaobjects.test_booking_slot
  | query: "fields.stylist:$s -fields.status:available",
    s: s

StylistOpenBooked
Alex
Bobbie
Cassie
Jenna
Martha
Sally

Pagination

Each filtered list has its own page key, so two paginated lists on one page page separately.

shop.metaobjects.test_booking_slot
  | query: "fields.status:available"
,
    sort_key: "fields.slot_number"
Liquid error (sections/stylist-slots line 152): Array 'paged_slots' is not paginateable.

Merchant-editable filter

Bindings come from section settings, so merchants can change the filter in the theme editor without touching code.

shop.metaobjects.test_booking_slot
  | query: "fields.stylist:$who fields.status:$status",
    who: section.settings.stylist, status: section.settings.status

slots for Jenna with status available

No matching slots.