Auto-Generated Data FILTERS For easy high speed searching |
METHOD dataFilter( index, searchstr, pglen )
local a, opts
opts = new( 'objFilterParams', index, searchstr )
switch ( opts.index )
case ::ORDER_LNAME
opts.init( {
{ 40 },
{ 30 },
{ 30 }
} )
a = {
{ 'index', opts.index },
{ 'key', opts.key },
{ 'filter', {
{ 'lname', '=^', opts.p1 },
{ 'fname', '=^', opts.p2 },
{ 'mname', '=^', opts.p3 }
}
}
}
break
end
if ( pglen )
a = ::dataFilterSet( a, 'pglen', pglen )
end
return( a )
END
Advanced Filter Commands
= equals (matches val length)
=^ equals (matches val length) [converts strings to uppercase]
== equals (matches field length)
==^ equals (matches field length) [converts strings to uppercase]
* contains
*^ contains [converts strings to uppercase]
< less than
<^ less than [upper]
<= less than or equal
<=^ less than or equal [upper]
> greater than
>^ greater than [upper]
>= greater than or equal
>=^ greater than or equal [upper]
!= not equal
!=^ not equal [upper]
!* not contained
!*^ not contained [upper]
? match wildcard
?^ match wildcard [upper]
=& soundex (of upper)
Rx upper( right ) 'x' chars
|
Auto-Generated Data TEMPLATES For automated interactive report generation |
METHOD dataTemplate( template )
local a, x, o
switch( lower( '' + template ) )
case '' + ::ORDER_NAME
a = {
{ 'tableClass', 'table defTbl' },
{ 'rowClick', "doClick('#id#');" },
{ 'fields', {
{ 'name',, { |x,o| o.name + ", " + o.fname +
" " + o.mname } },
{ 'gender' },
{ 'race',, { |x| self.raceDesc(x) } },
{ 'age',, { |x,o| self.age(x,o) } },
{ 'dob',, { |x| keytodate( x ) } },
{ 'status',, { |x| self.statusDesc(x) } },
{ 'edate',, { |x| keytodatetime(x,0,1) } },
{ 'id', { { 'editType', 'hidden' } } }
}
}
}
break
end
return( a )
END
|
Process Query Results with Map Functions |
Map Processing:
! "Show Fields:\r\n"
a = aResults.map().fields()
! objToJSON( a ) + "\r\n"
! "Sum Some Data:\r\n"
a = aResults.aMapSum( "age;playingDays" )
! objToJSON( a ) + "\r\n"
! "Get Averages:\r\n"
a = aResults.aMapAverage( "age;playingDays" )
! objToJSON( a ) + "\r\n"
! "Accumulate Data by Groups:\r\n"
accumulator = aArray().add( {
{ "France", {} },
{ "England", {} },
{ "Spain", {} }
} )
a = aResults.aMapReduce( "soccerSortByCountry", accumulator )
! objToJSON( aArrayToJSON( a, 1 ) )
Map Results:
Show Fields:
[
"GENDER",
"NAME",
"AGE",
"CLUB",
"COUNTRY",
"DATA",
"PLAYINGDAYS"
]
Sum Some Data:
{
age : 165.0,
playingDays : 949.0
}
Get Averages:
{
age : 27.50,
playingDays : 158.1666666670
}
Accumulate Data by Groups:
{
England : [
{
gender : "M",
name : "Riyad Mahrez",
age : 25,
club : "Leicester City FC",
country : "England",
data : {
desc : "Riyad Mahrez, Leicester City FC, England"
},
playingDays : 132
},
{
gender : "M",
name : "Sofiane Feghouli",
age : 26,
club : "West Ham United",
country : "England",
data : {
desc : "Sofiane Feghouli, West Ham United, England"
},
playingDays : 45
}
],
France : [
{
gender : "M",
name : "Hatem Ben Arfa",
age : 29,
club : "PSG",
country : "France",
data : {
desc : "Hatem Ben Arfa, PSG, France"
},
playingDays : 180
},
{
gender : "M",
name : "Radamel Falcao",
age : 27,
club : "AS Monaco FC",
country : "France",
data : {
desc : "Radamel Falcao, AS Monaco FC, France"
},
playingDays : 22
}
],
Spain : [
{
gender : "M",
name : "Karim Benzema",
age : 29,
club : "Real Madrid CF",
country : "Spain",
data : {
desc : "Karim Benzema, Real Madrid CF, Spain"
},
playingDays : 200
},
{
gender : "M",
name : "Samir Nasri",
age : 29,
club : "Sevilla FC",
country : "Spain",
data : {
desc : "Samir Nasri, Sevilla FC, Spain"
},
playingDays : 370
}
]
}
|