query.some()
This function calls a given closure/function with every element in a given query and returns true, if one of the closure calls returns true.
query.some( closure=function, parallel=boolean, maxThreads=number )
Returns: Boolean
Examples
people = QueryNew( "name,dob,age", "varchar,date,int", [
[ "Susi", CreateDate( 1970, 1, 1 ), 0 ],
[ "Urs" , CreateDate( 1995, 1, 1 ), 0 ],
[ "Fred", CreateDate( 1960, 1, 1 ), 0 ],
[ "Jim" , CreateDate( 1988, 1, 1 ), 0 ]
]);
<span class="nf">Dump</span><span class="p">(</span> <span class="k">var</span><span class="o">=</span><span class="nv">people</span><span class="p">,</span> <span class="nv">label</span><span class="o">=</span><span class="s2">"people - original query"</span> <span class="p">);</span>
<span class="o">/*</span> <span class="nv">Output</span><span class="p">:</span>
<span class="err">|</span> <span class="nv">name</span> <span class="err">|</span> <span class="nv">dob</span> <span class="err">|</span> <span class="nv">age</span> <span class="err">|</span>
<span class="o">------------------------------------</span>
<span class="err">|</span> <span class="nv">Susi</span> <span class="err">|</span> <span class="m">1970</span><span class="o">-</span><span class="m">01</span><span class="o">-</span><span class="m">01</span> <span class="m">00</span><span class="p">:</span><span class="m">00</span><span class="p">:</span><span class="m">00</span> <span class="err">|</span> <span class="m">0</span> <span class="err">|</span>
<span class="err">|</span> <span class="nv">Urs</span> <span class="err">|</span> <span class="m">1995</span><span class="o">-</span><span class="m">01</span><span class="o">-</span><span class="m">01</span> <span class="m">00</span><span class="p">:</span><span class="m">00</span><span class="p">:</span><span class="m">00</span> <span class="err">|</span> <span class="m">0</span> <span class="err">|</span>
<span class="err">|</span> <span class="nv">Fred</span> <span class="err">|</span> <span class="m">1960</span><span class="o">-</span><span class="m">01</span><span class="o">-</span><span class="m">01</span> <span class="m">00</span><span class="p">:</span><span class="m">00</span><span class="p">:</span><span class="m">00</span> <span class="err">|</span> <span class="m">0</span> <span class="err">|</span>
<span class="err">|</span> <span class="nv">Jim</span> <span class="err">|</span> <span class="m">1988</span><span class="o">-</span><span class="m">01</span><span class="o">-</span><span class="m">01</span> <span class="m">00</span><span class="p">:</span><span class="m">00</span><span class="p">:</span><span class="m">00</span> <span class="err">|</span> <span class="m">0</span> <span class="err">|</span>
<span class="o">*/</span>
<span class="c">// data validation - age between 0 and 120</span>
<span class="nv">valid</span> <span class="o">=</span> <span class="nf">people.some</span><span class="p">(</span><span class="nf">function</span><span class="p">(</span><span class="nv">row</span><span class="p">,</span> <span class="nv">rowNumber</span><span class="p">,</span> <span class="nv">qryData</span><span class="p">){</span>
<span class="nf">return</span> <span class="p">((</span><span class="nf">DateDiff</span><span class="p">(</span><span class="s1">'yyyy'</span><span class="p">,</span> <span class="nv">row.dob</span><span class="p">,</span> <span class="nf">Now</span><span class="p">())</span> <span class="o">></span> <span class="m">0</span><span class="p">)</span> <span class="o">&&</span> <span class="p">(</span><span class="nf">DateDiff</span><span class="p">(</span><span class="s1">'yyyy'</span><span class="p">,</span> <span class="nv">row.dob</span><span class="p">,</span> <span class="nf">Now</span><span class="p">())</span> <span class="o"><=</span> <span class="m">100</span><span class="p">))</span>
<span class="p">});</span>
<span class="nf">dump</span><span class="p">(</span><span class="k">var</span><span class="o">=</span><span class="nv">valid</span><span class="p">,</span> <span class="nv">label</span><span class="o">=</span><span class="s1">'age between 0 and 120'</span><span class="p">);</span>
<span class="o">/*</span> <span class="nv">Output</span><span class="p">:</span> <span class="nv">true</span> <span class="o">*/</span>
<span class="c">// data validation - age between 10 and 20</span>
<span class="nv">valid</span> <span class="o">=</span> <span class="nf">people.some</span><span class="p">(</span><span class="nf">function</span><span class="p">(</span><span class="nv">row</span><span class="p">,</span> <span class="nv">rowNumber</span><span class="p">,</span> <span class="nv">qryData</span><span class="p">){</span>
<span class="nf">return</span> <span class="p">((</span><span class="nf">DateDiff</span><span class="p">(</span><span class="s1">'yyyy'</span><span class="p">,</span> <span class="nv">row.dob</span><span class="p">,</span> <span class="nf">Now</span><span class="p">())</span> <span class="o">></span> <span class="m">1</span><span class="p">)</span> <span class="o">&&</span> <span class="p">(</span><span class="nf">DateDiff</span><span class="p">(</span><span class="s1">'yyyy'</span><span class="p">,</span> <span class="nv">row.dob</span><span class="p">,</span> <span class="nf">Now</span><span class="p">())</span> <span class="o"><=</span> <span class="m">10</span><span class="p">))</span>
<span class="p">});</span>
<span class="nf">dump</span><span class="p">(</span><span class="k">var</span><span class="o">=</span><span class="nv">valid</span><span class="p">,</span> <span class="nv">label</span><span class="o">=</span><span class="s1">'age between 1 and 10'</span><span class="p">);</span>
<span class="o">/*</span> <span class="nv">Output</span><span class="p">:</span> <span class="nv">false</span> <span class="o">*/</span>