Simplified filter syntax for simple tasks

Author: Peter Aron Zentai April 18th, 2013


Querying is one of the most important aspects of a good data management library. JayData was always very strong at this with using natural JavaScript expressions as vehicles to transfer the developer intention into storage specific things.

Good old JSLQ

So to express “Completed Tasks” in the past we could simply write

or with the string from and using parameters

This is pure JavaScript syntax and has the benefits of already well documented and needs no learning. To express something more complex you do what you’d do otherwise in JavaScript: use logical operators.

Most of the time however we simply need to just “filter” for some field values without anything complex. 80% of the time we really do not use the power of the full fledged syntax, yet we always have to pay some extra characters to endorse it. So why don’t we just have…

NEW! …the filter(field, op, value) syntax

On top of the function and string based predicate syntax as of JayData 1.3 you can use a simple builder syntax to support simplex query scenarios – we call this internally the “BreezeJS syntax”. This syntax helps code generated filters to be created more easily but what is more important: let’s you express simple things even more simpler:

You can chain filter() statements to create and expressions

You can use all the operators you are familiar with (even the bitwise ones). To express method based expressions like contains or startsWith signify it with a dot (“.”)

Search on navigation properties:

Limitations for the simplified syntax:

Well everything that comes from it’s simplicity. You can not express in row expressions (field1 > field2), and complex expression (field1 % 2 == 0). Also grouping and the use of the or logic operator requires full JSLQ syntax.

To get these working you’ll need the build from the JayData 1.3 master branch from github. – or after the release get the JayData 1.3 download package from JayData.

How we should never…

The JavaScript syntax ‘covers it all’ and gives you language elements to express complicated filters in a line or two in a way you already know. Instead some libraries require you to build complex expression trees with methods, as for example BreezeJS do: