The .where() can be called anywhere after the .from() and before the .select(). The .where() function can either take a string for the condition to use or a predicate.

📘

Multiple .where()s can be used multiple times throughout a single query!

Introduced in version 1.5, the .filter() is synonymous to .where(), you can use them interchangeably.

The .where() requires at least one parameter and is used for simple condition checking. Each parameter is the condition that must be true. Each parameter is combined as an And condition. If any of the conditions are not true then the row will be excluded in the result set. The following operators are supported: < > <= >= != == . The operator is used for contains.

🚧

If the R-Value contains spaces do not surround the value with single or double quotes.

String Parameters

where(string, string, string, ...)
filter(string, string, string, ...)
where(condition: string, ...conditions: string[]): jinqJs;

Predicate Parameter

The predicate() function will receive two arguments that is the row currently being iterated over and its index number. This allowing you to perform complex logic. The predicate() function must return true or false.

where( Function( row, index ) ) OR filter( Function( row, index ) )
type PredicateCondition<T> = (row: T, index: number) => boolean;
where<T>(predicate: PredicateCondition<T>): jinqJs;

Complex Collection

Simple Array

var result = new jinqJs()   //Filter out even #’s on an array of numbers
                 .from([1,2,3,4,5,6])
                 .where( function(row, index){ return row % 2 == 0; })
                 .select();

/* result:  [2,4,6] */