Skip to content

Commit fbb5459

Browse files
committed
Document MongoDB types.
1 parent a18c56e commit fbb5459

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

usage/sync-rules/types.mdx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Postgres values are mapped according to this table:
2626
| float4, float8 | real | |
2727
| enum | text | |
2828
| uuid | text | |
29-
| timestamptz | text | Format: YYYY-MM-DD hh:mm:ss.sssZThis is compatible with ISO8601 and SQLite's functions. Precision matches the precision used in Postgres.\-infinity becomes 0000-01-01 00:00:00Z and infinity becomes 9999-12-31 23:59:59Z. |
30-
| timestamp | text | Format: YYYY-MM-DD hh:mm:ss.sssIn most cases, timestamptz should be used instead.\-infinity becomes 0000-01-01 00:00:00 and infinity becomes 9999-12-31 23:59:59. |
29+
| timestamptz | text | Format: `YYYY-MM-DD hh:mm:ss.sssZ`. This is compatible with ISO8601 and SQLite's functions. Precision matches the precision used in Postgres. `-infinity` becomes `0000-01-01 00:00:00Z` and `infinity` becomes `9999-12-31 23:59:59Z`. |
30+
| timestamp | text | Format: `YYYY-MM-DD hh:mm:ss.sss`. In most cases, timestamptz should be used instead. `-infinity` becomes `0000-01-01 00:00:00` and `infinity` becomes `9999-12-31 23:59:59`. |
3131
| date, time | text | |
3232
| json, jsonb | text | There is no dedicated JSON type — JSON functions operate directly on text values. |
3333
| interval | text | |
@@ -46,11 +46,33 @@ There is no dedicated boolean data type. Boolean values are represented as `1` (
4646
This section is a work in progress. More details for MongoDB connections are coming soon. In the meantime, check our [MongoDB guide](/migration-guides/mongodb-atlas) to try out our MongoDB alpha support, and ask on our [Discord server](https://discord.gg/powersync) if you have any questions.
4747
</Info>
4848

49+
| BSON Type | PowerSync / SQLite Column Type | Notes |
50+
| ------------------ | ------------------------------ | ----- |
51+
| String | text | |
52+
| Int, Long | integer | |
53+
| Double | real | |
54+
| Decimal128 | text | |
55+
| Object | text | Converted to a JSON string |
56+
| Array | text | Converted to a JSON string |
57+
| ObjectId | text | Lower-case hex string |
58+
| UUID | text | Lower-case hex string |
59+
| Boolean | integer | 1 for true, 0 for false |
60+
| Date | text | Format: `YYYY-MM-DD hh:mm:ss.sss` |
61+
| Null | null | |
62+
| Binary | blob | Cannot sync directly to client — convert to hex or base64 first. See [Operators & Functions](/usage/sync-rules/operators-and-functions). |
63+
| Regular Expression | text | JSON text in the format `{"pattern":"...","options":"..."}` |
64+
| Timestamp | integer | Converted to a 64-bit integer |
65+
| Undefined | null | |
66+
| DBPointer | text | JSON text in the format `{"collection":"...","oid":"...","db":"...","fields":...}` |
67+
| JavaScript | text | JSON text in the format `{"code": "...", "scope": ...}` |
68+
| Symbol | text | |
69+
| MinKey, MaxKey | null | |
70+
4971
* Data is converted to a flat list of columns, one column per top-level field in the MongoDB document.
5072
* Special BSON types are converted to plain SQLite alternatives.
5173
* For example, `ObjectId`, `Date`, `UUID` are all converted to a plain `TEXT` column.
5274
* Nested objects and arrays are converted to JSON arrays, and JSON operators can be used to query them (in the Sync Rules and/or on the client-side).
53-
75+
* Binary data nested in objects or arrays is not supported.
5476

5577
## <Icon icon="dolphin" iconType="solid" size="24"/> MySQL (Alpha) Type Mapping
5678

0 commit comments

Comments
 (0)