new searchQuery()
Search Query object to validate user input for SQL queries.
Contains a list of all used parameters for all queries.
User input is compared to this parameters, and validated.
Data members of this object are guaranteed to be valid.
Applies %% wrapping when appropriate.
Members
(static) contains :Array.<string>
Array of all ingredients which must be required by a drink
Type:
- Array.<string>
(static) drinkId :number
ID of the drink, but with different validation.
Defaults to 0.
Type:
- number
(static) glass :string
ID of the glass drink must be drunk from
"" for any glass.
Type:
- string
(static) id :string
ID of the drink
"" for any drink.
Type:
- string
(static) isSweet :string
If a drink contains a sweet ingredient.
"1" for sweet.
"0" for savoury.
"" for either or anything.
Type:
- string
(static) liquor :string
If a drink contains a liquor or liquer.
"1" for liquor.
"0" for liquer.
"" for either or anything.
Type:
- string
(static) mixMethod :string
Method of mixing drink.
Can be either "shaken" or "stirred".
"" for either.
Type:
- string
(static) name :string
Name (used mainly for drink name, but can also refer to ingredient names)
Type:
- string
(static) onIce :string
If a drink is on the rocks.
"1" for ice.
"0" for no ice.
"" for either.
Type:
- string
(static) orderedBy :string
User who ordered a drink
Type:
- string
(static) percentage :number
Minimum alcohol percentage.
Defaults to 0.
Type:
- number
(static) price :number
Maximum drink price
Defaults to 100.
Type:
- number
(static) rating :number
Minimum drink rating
Defaults to 0.
Type:
- number
(static) userDob :string
Date of birth of person ordering drink.
Defaults to Jan 1st 1970.
Type:
- string
(static) userName :string
Username of person ordering drink.
Defaults to Unknown Name
Type:
- string
Methods
(static) getArgs() → {Array.<string>}
Generates an appropriate ordered list of parameters for the advanced search query.
Returns:
Ordered list of SQL parameters
- Type
- Array.<string>
(static) reset()
Resets all string datamembers to empty
(static) sanitzize()
Where the magic happens. Iterates over all datamembers and applies both
general and specific sanitzization. Inputs still must be injected via
a prepared statement.
(static) update(params)
Adds all given parameters of params as datamembers
In practice this updates datamembers with all recognizable attributes
in the given object. This means that extra clutter will not be injected.
Parameters:
Name | Type | Description |
---|---|---|
params |
object | Object of key/value pairs to record. |