Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions usage/sync-rules/operators-and-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,33 @@ 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)`<br/>`x :: type` | Cast to text, numeric, integer, real or blob. |
| JSON | `json -> 'path'`<br/> `json ->> 'path'` | `->` Returns the value as a JSON string.<br/> `->>` Returns the extracted value. |
| Text concatenation | `\|\|` | Joins two text values together. |
| Arrays | `<left> IN <right>` | 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:<br/> `= != < > <= >=` | If either parameter is null, this evaluates to null. |
| Null:<br/> `IS NULL`, `IS NOT NULL` | |
| Mathematical:<br/> `+ - * /` | |
| Logical:<br/> `AND`, `OR`, `NOT` | |
| Cast:<br/> `CAST(x AS type)`<br/>`x :: type` | Cast to text, numeric, integer, real or blob. |
| JSON:<br/> `json -> 'path'`<br/>`json ->> 'path'` | `->` Returns the value as a JSON string.<br/> `->>` Returns the extracted value. |
| Text concatenation:<br/> `\|\|` | Joins two text values together. |
| Arrays:<br/> `<left> IN <right>` | Returns true if the `left` value is present in the `right` JSON array.<br/>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.<br/>Differs from the SQLite operator in that it can be used directly on a JSON array. |

### Functions

| Function | Description |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [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. |
Expand Down
4 changes: 2 additions & 2 deletions usage/tools/monitoring-and-alerting.mdx
Original file line number Diff line number Diff line change
@@ -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)
Expand Down