diff --git a/usage/sync-rules/operators-and-functions.mdx b/usage/sync-rules/operators-and-functions.mdx index aaa9dd9f..3f4e7aee 100644 --- a/usage/sync-rules/operators-and-functions.mdx +++ b/usage/sync-rules/operators-and-functions.mdx @@ -17,16 +17,16 @@ Some fundamental restrictions on these operators and functions are: ### Operators -| Category | Operators | Notes | -| ------------------ | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| Comparison | `= != < > <= >=` | If either parameter is null, this evaluates to null. | -| Null | `IS NULL`, `IS NOT NULL` | | -| Mathematical | `+ - * /` | | -| Logical | `AND`, `OR`, `NOT` | | -| Cast | `CAST(x AS type)`
`x :: type` | Cast to text, numeric, integer, real or blob. | -| JSON | `json -> 'path'`
`json ->> 'path'` | `->` Returns the value as a JSON string.
`->>` Returns the extracted value. | -| Text concatenation | `\|\|` | Joins two text values together. | -| Arrays | ` IN ` | Returns true if the `left` value is present in the `right` JSON array. In data queries, only the `left` value may be a bucket parameter. In parameter queries, the `left` or `right` value may be a bucket parameter. Differs from the SQLite operator in that it can be used directly on a JSON array. | +| Operator | Notes | +| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| Comparison:
`= != < > <= >=` | If either parameter is null, this evaluates to null. | +| Null:
`IS NULL`, `IS NOT NULL` | | +| Mathematical:
`+ - * /` | | +| Logical:
`AND`, `OR`, `NOT` | | +| Cast:
`CAST(x AS type)`
`x :: type` | Cast to text, numeric, integer, real or blob. | +| JSON:
`json -> 'path'`
`json ->> 'path'` | `->` Returns the value as a JSON string.
`->>` Returns the extracted value. | +| Text concatenation:
`\|\|` | Joins two text values together. | +| Arrays:
` IN ` | Returns true if the `left` value is present in the `right` JSON array.
In data queries, only the `left` value may be a bucket parameter. In parameter queries, the `left` or `right` value may be a bucket parameter.
Differs from the SQLite operator in that it can be used directly on a JSON array. | ### Functions @@ -34,15 +34,16 @@ Some fundamental restrictions on these operators and functions are: | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | [upper(text)](https://www.sqlite.org/lang_corefunc.html#upper) | Convert text to upper case. | | [lower(text)](https://www.sqlite.org/lang_corefunc.html#lower) | Convert text to lower case. | -| [substring(text, start, length)](https://sqlite.org/lang_corefunc.html#substr) | Extracts a portion of a string based on specified start index and length. Start index is 1-based. | +| [substring(text, start, length)](https://sqlite.org/lang_corefunc.html#substr) | Extracts a portion of a string based on specified start index and length. Start index is 1-based. Example: `substring(created_at, 1, 10)` returns the date portion of the timestamp. | | [hex(data)](https://www.sqlite.org/lang_corefunc.html#hex) | Convert blob or text data to hexadecimal text. | | base64(data) | Convert blob or text data to base64 text. | | [length(data)](https://www.sqlite.org/lang_corefunc.html#length) | For text, return the number of characters. For blob, return the number of bytes. For null, return null. For integer and real, convert to text and return the number of characters. | | [typeof(data)](https://www.sqlite.org/lang_corefunc.html#typeof) | text, integer, real, blob or null | +| [json\_each(data)](https://www.sqlite.org/json1.html#jeach) | Expands a JSON array or object from a request or token parameter into a set of parameter rows. Example: `SELECT value as project_id FROM json_each(request.jwt() -> 'project_ids'` | | [json\_extract(data, path)](https://www.sqlite.org/json1.html#jex) | Same as `->>` operator, but the path must start with `$.` | | [json\_array\_length(data)](https://www.sqlite.org/json1.html#jarraylen) | Given a JSON array (as text), returns the length of the array. If data is null, returns null. If the value is not a JSON array, returns 0. | | [json\_valid(data)](https://www.sqlite.org/json1.html#jvalid) | Returns 1 if the data can be parsed as JSON, 0 otherwise. | -| json\_keys(data) | Returns the set of keys of a JSON object as a JSON array. | +| json\_keys(data) | Returns the set of keys of a JSON object as a JSON array. Example: `select * from items where bucket.user_id in json_keys(permissions_json)` | | [ifnull(x,y)](https://www.sqlite.org/lang_corefunc.html#ifnull) | Returns x if non-null, otherwise returns y. | | [unixepoch(datetime, \[modifier\])](https://www.sqlite.org/lang_datefunc.html) | Returns a datetime as Unix timestamp. If modifier is "subsec", the result is a floating point number, with milliseconds including in the fraction. The datetime argument is required - this function cannot be used to get the current time. | | [datetime(datetime, \[modifier\])](https://www.sqlite.org/lang_datefunc.html) | Returns a datetime as a datetime string, in the format YYYY-MM-DD HH:MM:SS. If the specifier is "subsec", milliseconds are also included. If the modifier is "unixepoch", the argument is interpreted as a unix timestamp. Both modifiers can be included: datetime(timestamp, 'unixepoch', 'subsec'). The datetime argument is required - this function cannot be used to get the current time. | diff --git a/usage/tools/monitoring-and-alerting.mdx b/usage/tools/monitoring-and-alerting.mdx index cafffee3..bb8128e6 100644 --- a/usage/tools/monitoring-and-alerting.mdx +++ b/usage/tools/monitoring-and-alerting.mdx @@ -1,9 +1,9 @@ --- title: Monitoring and Alerting -description: Overview of monitoring and alerting functionality for PowerSync instances +description: Overview of monitoring and alerting functionality for PowerSync Cloud instances --- -You can monitor activity and alert on issues and usage for your PowerSync instance(s): +You can monitor activity and alert on issues and usage for your PowerSync Cloud instance(s): * **Monitor Usage**: View time-series and aggregated usage data with [Usage Metrics](#usage-metrics) * **Monitor Service and Replication Activity**: Track your PowerSync service and replication logs with [Instance Logs](#instance-logs)