Menu

Expand
Rate this page:

Live Query Language

For Flex customers only

Queries are written in infix notation in the form 'field [operator] "value"'. Only string types are supported for values.

Index name:

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.

Query operators:

Operator Description Alternative forms Example
and Logical AND operation. and, AND, && a == "b" AND c != "d"
or Logical OR operation. or, OR, || a == "b" OR c != "d"
in Evaluates whether an attribute's value matches an element (possibly many) from the given array. in, IN field IN ["value1", "value2"]
eq Checks if an attribute has a specified value. eq, EQ, == field EQ "value"
not_in Evaluates whether an attribute has any values other than those specified in the given array. not_in, NOT_IN field NOT_IN ["value1", "value2"]
not_eq Checks if an attribute has any values other than the given one. not_eq, NOT_EQ, != field NOT_EQ "value"
contains Checks if an attribute value string contains a substring contains, CONTAINS field CONTAINS "value"
() Start and end of evaluation block, determines operator precedence. n/a (field == "value" OR lang IN ["es", "en"]) AND team EQ "engineering"
[] Start and end of array block, enumerates a list of elements. n/a ["value1", "value2"]
, Comma is used to separate elements in array. n/a n/a
"..." Value of a string type must be double-quoted within the query expression. n/a n/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:

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

Using empty string for wildcard search.

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

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

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

        
        
        

        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more