Operators

Multiple (Any)

Any/At least one of. Learn how to use multiple value operators in pb-query.

Useful for queries involving back-relations, multiple relation, multiple select, or multiple file.

Return all authors who have published at least one book about "Harry Potter":

pbQuery<Book>().anyLike('books_via_author.title', 'Harry Potter'); // post_via_author.name?~'Harry Potter'

Return all authors who have only published books about "Harry Potter":

pbQuery<Book>().like('books_via_author.title', 'Harry Potter'); // post_via_author.name~'Harry Potter'
Back-relations by default are resolved as multiple relation field (see the note with the caveats), meaning that similar to all other multi-valued fields (multiple relation, select, file) by default a "match-all" constraint is applied and if you want "any/at-least-one" type of condition then you'll have to prefix the operator with ?.

Equality Checks

.anyEqual(key, value)

Matches records where at least one of the values in the given key equals value.

pbQuery<Book>().anyEqual('books_via_author.title', 'The Island'); // post_via_author.name?='The Island'

// This is case-sensitive. Use the `:lower` modifier for case-insensitive matching.
pbQuery<Book>().anyEqual('books_via_author.title:lower', 'the island'); // post_via_author.name:lower?='the island'

.anyNotEqual(key, value)

Matches records where at least one of the values in the given key is not equal to value.

pbQuery<Book>().anyNotEqual('books_via_author.title', 'The Island'); // post_via_author.name?!='The Island'

// This is case-sensitive. Use the `:lower` modifier for case-insensitive matching.
pbQuery<Book>().anyNotEqual('books_via_author.title:lower', 'the island'); // post_via_author.name:lower?!='the island'

.anyLike(key, value)

Matches records where at least one of the values in the given key contains value.

It is case-insensitive, so the :lower modifier is unnecessary.

pbQuery<Post>().anyLike('author.name', 'Joh'); // name?~'Joh' / name?~'%Joh%'

.anyNotLike(key, value)

Matches records where at least one of the values in the given key doesn't contain value.

It is case-insensitive, so the :lower modifier is unnecessary.

pbQuery<Post>().anyNotLike('author.name', 'Joh'); // name?!~'Joh' / name?!~'%Joh%'

Comparisons

.anyGreaterThan(key, value)

Matches records where at least one of the values in the given key is greater than value.

pbQuery<User>().anyGreaterThan('age', 21); // age?>21

.anyGreaterThanOrEqual(key, value)

Matches records where at least one of the values in the given key is greater than or equal to value.

pbQuery<User>().anyGreaterThanOrEqual('age', 18); // age?>=18

.anyLessThan(key, value)

Matches records where at least one of the values in the given key is less than value.

pbQuery<User>().anyLessThan('age', 50); // age?<50

.anyLessThanOrEqual(key, value)

Matches records where at least one of the values in the given key is less than or equal to value.

pbQuery<User>().anyLessThanOrEqual('age', 65); // age?<=65