Skip to contentSkip to navigationSkip to topbar
Rate this Page:

Live Query Language


The Live Query Language allows Flex customers to get basic information about their Flex instance from Sync. Queries are written in infix notation in the form 'field [operator] "value"'. Only string types are supported for values.

The examples on this page use the Sync SDK.


Index name

index-name page anchor

Index name is a data class for which Live Queries are available. Currently, supported index names for Flex are: tr-task, tr-worker, tr-reservation, tr-queue.

(warning)

Warning

The TaskQueue list may not include all TaskQueues if the TaskQueue has not been used for 30 days or more. Reset the expiration on your TaskQueue by routing an inbound task to the Queue. Each additional task and any transfers will reset the expiration time to 30 days.


OperatorDescriptionAlternative formsExample
andLogical AND operation.and, AND, &&a == "b" AND c != "d"
orLogical OR operation.or, OR, ||a == "b" OR c != "d"
inEvaluates whether an attribute's value matches an element (possibly many) from the given array.in, INfield IN ["value1", "value2"]
eqChecks if an attribute has a specified value.eq, EQ, ==field EQ "value"
not_inEvaluates whether an attribute has any values other than those specified in the given array.not_in, NOT_INfield NOT_IN ["value1", "value2"]
not_eqChecks if an attribute has any values other than the given one.not_eq, NOT_EQ, !=field NOT_EQ "value"
containsChecks if an attribute value string contains a substringcontains, CONTAINSfield CONTAINS "value"
()Start and end of evaluation block, determine operator precedence.n/a(field == "value" OR lang IN ["es", "en"]) AND team EQ "engineering"
[]Start and end of array block, enumerate a list of elements.n/a["value1", "value2"]
,Comma is used to separate elements in array.n/an/a
"..."Value of a string type must be double-quoted within the query expression.n/an/a

* Sync Client has a number of limits in place which will constrain certain query expressions. Please check Sync Client Limits page for more information.

Subscribing to live updates for worker Bob

subscribing-to-live-updates-for-worker-bob page anchor

_14
const SyncClient = require('twilio-sync');
_14
_14
syncClient.liveQuery('tr-worker', 'data.attributes.worker_name == "Bob"')
_14
.then(function (args) {
_14
console.log('Subscribed to live data updates for worker Bob');
_14
let items = args.getItems();
_14
Object.entries(items).forEach(([key, value]) => {
_14
console.log('Search result item key: ' + key);
_14
console.log('Search result item value: ' + value);
_14
});
_14
})
_14
.catch(function (err) {
_14
console.log('Error when subscribing to live updates for Bob', err);
_14
});

using-empty-string-for-wildcard-search page anchor

As currently max response size is 200 records, the code example below will subscribe us to up to 200 workers.


_14
const SyncClient = require('twilio-sync');
_14
_14
syncClient.liveQuery('tr-worker', '')
_14
.then(function (args) {
_14
console.log('Subscribed to live data updates for workers');
_14
let items = args.getItems();
_14
Object.entries(items).forEach(([key, value]) => {
_14
console.log('Search result item key: ' + key);
_14
console.log('Search result item value: ' + value);
_14
});
_14
})
_14
.catch(function (err) {
_14
console.log('Error when subscribing to live updates', err);
_14
});;


Rate this Page: