The CBFS Storage query language supports a wide variety of language elements, all of which are described below.
|NOT, !, ~||Boolean||Logical negation (NOT)|
|NOT, !, ~||Number||Bitwise NOT|
|AND, &||Boolean||Logical AND|
|AND, &||Number||Bitwise AND|
|OR, |||Boolean||Logical OR|
|OR, |||Number||Bitwise OR|
|/||Number||Division (attempting to divide by zero will cause an exception)|
Addition and subtraction operations involving DateTime operands behave as follows:
- When adding a Number (n) and a DateTime, the result is a DateTime whose value has increased by n whole days.
- When subtracting a Number (n) from a DateTime, the result is a DateTime whose value has decreased by n whole days.
- When subtracting a DateTime from another DateTime, the result is a Number which reflects the difference as a number of whole days. The query evaluator converts both operands to whole days before performing the subtraction; "leftover" time is truncated as part of the conversion.
|=, ==||All types||Equal to|
|<>, !=||All types||Not equal to|
|<||All types||Less than|
|>||All types||Greater than|
|<=||All types||Less than or equal to|
|>=||All types||Greater than or equal to|
|IS [NOT] NULL||All types||Returns True if the value is/isn't NULL, and False otherwise.|
|IS [NOT] True||Boolean||Returns True if the value is/isn't True, and False otherwise.|
|IS [NOT] False||Boolean||Returns True if the value is/isn't False, and False otherwise.|
|[NOT] LIKE '...' [ESCAPE '...']||String||Returns True if the value does/doesn't match the specified pattern; see notes below.|
Keep the following in mind when using the LIKE condition:
- Two kinds of wildcards are supported: %, which matches a string of any length; and _, which matches any single character. For example:
- From LIKE '% Smith': Selects all files received from people with the last name "Smith".
- From LIKE 'John Sm_th': Selects all files received from people with the first name "John" and a last name that is five characters long, begins with "Sm", and ends with "th" (Smith, Smyth, Smeth, etc.).
- To search for values which include wildcard characters, the optional ESCAPE parameter can be used to specify a wildcard escape character. For example:
- From LIKE 'John!_Smith' ESCAPE '!': Selects all files received from "John_Smith".
- From LIKE 'John!_%' ESCAPE '!': Selects all files received from a name that begins with "John_".
File variables represent some piece of information about the current file the query is being evaluated against.
|FileName||String||The name of the current file.|
|FullName||String||The fully-qualified name of the current file, starting from the root directory /.|
|Path||String||The full path to the current file, including the final path separator (not including the file name).|
|IsFile||Boolean||True if the current file is not a directory, and False otherwise.|
|IsDirectory||Boolean||True if the current file is a directory, and False otherwise.|
|IsLink||Boolean||True if the current file is a symbolic link, and False otherwise.|
|LinkDestination||String||If the current file is a symbolic link, the link's target; otherwise acts the same as FullName.|
|CreationTime||DateTime||The current file's creation date and time.|
|LastAccessTime||DateTime||The current file's last access date and time.|
|ModificationTime||DateTime||The current file's last modification date and time.|
|Size||Number||The size of the current file (always 0 for directories).|
|Attributes||Number||The current file's attribute, encoded as a number.|
|IsEncrypted||Boolean||True if the current file is encrypted, and False otherwise.|
|IsCompressed||Boolean||True if the current file is compressed, and False otherwise. May be True for directories that contain files compressed by default.|
"Intrinsics" are the functions and constants built into the query language.
|Intrinsic||Operand type(s)||Return type||Description|
|D(value)||String||DateTime||Converts a String to a DateTime; please refer to the Type Conversion topic for more information.|
|IsNull(value)||All types||Boolean||Returns True if the value is NULL, and False otherwise.|
|IsNotNull(value)||All types||Boolean||Returns True if the value is not NULL, and False otherwise.|
|Min(value1, value2)||All types||All types||Returns the smaller of the two values.|
|Max(value1, value2)||All types||All types||Returns the larger of the two values.|
|Now||DateTime||Returns the current system date and time.|
|Today||DateTime||Returns the current system date.|
The table below lists the query language's elements in order of descending precedence. Any legal expression within a query string may be surrounded with parentheses () in order to override precedence or increase readability.
|1||All File Variables|
All Intrinsics (except D(value); see note)
|2||-: Arithmetic negation|
NOT, !, ~: Logical/bitwise negation
D(value): Explicit String to DateTime conversion
|4||+: Addition/string concatenation|
|5||=, ==: Equal to|
<>, !=: Not equal to
<: Less than
>: Greater than
<=: Less than or equal to
>=: Greater than or equal to
IS [NOT], [NOT] LIKE: All Conditions
|6||AND, &: Logical/bitwise AND|
|7||OR, |: Logical/bitwise OR|