Find a container by held key
Which bin holds order ORD-9 is one GIN-indexed containment query on the bin rows. No side table tracks membership.
The situation
A customer calls about order ORD-9. Support needs to know which bin it sits in right now, among hundreds of open bins.
The recipe
curl -G https://lt.acme.dev/api/escalations \ -H "Authorization: Bearer $TOKEN" \ --data-urlencode 'role=bin' \ --data-urlencode 'status=pending' \ --data-urlencode 'facets={"accumulate_keys":["ORD-9"]}'const { data } = await lt.escalations.list({ role: 'bin', status: 'pending', facets: { accumulate_keys: ['ORD-9'] },});const bin = data?.escalations[0];Every add and remove recomputes metadata.accumulate_keys, the list of keys the container holds. Containment on an array matches any row whose list includes the value.
The guarantee
accumulate_keys is rewritten in the same statement as the add or removal, so the index never lags the container. The reverse question reads from the item’s side: after a reciprocal add, the bag’s own row holds the bin’s id. Facet selectors such as accumulateByMetadata consider only pending rows that carry the accumulator declaration, ordered by priority then age. See Batches and accumulators.
Related patterns
The escalation boundary
Reciprocal add
A bag joins a bin and the bin records the bag in one statement. Both rows change or neither.
The escalation boundary
Open container
One row is a container that fills over time. Items join one at a time and the workflow wakes once with the ordered collection.
The queue as a market
Lot traceability by containment
Stamp the lots each unit consumed onto its row as an array facet. Every row that used a lot is then one containment query.
The queue as a market
A query that fits in a URL
Facets, ranges, exclusions and ordering ride as JSON query params, so any filtered queue is a link you can paste, pin or curl.
