Skip to content
Merged
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
6 changes: 4 additions & 2 deletions usage/sync-rules/client-id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
```

<Info>
MongoDB uses `_id` as the name of the ID field in collections. Therefore, PowerSync requires using `SELECT _id as id` in [Sync Rule's](/usage/sync-rules) data queries when using MongoDB as the backend source database. When inserting new documents from the client, prefer `ObjectId` values for `_id` (stored in the client's `id` column).

Check warning on line 18 in usage/sync-rules/client-id.mdx

View check run for this annotation

Mintlify / Mintlify Validation (powersync) - vale-spellcheck

usage/sync-rules/client-id.mdx#L18

Did you really mean '_id'?
</Info>

Custom transformations could also be used for the ID, for example:
Custom transformations can also be used for the ID column. This is useful in certain scenarios for example when dealing with join tables, because PowerSync doesn't currently support composite primary keys. For example:

```sql
-- Concatenate multiple columns into a single id column
SELECT org_id || '.' || record_id as id FROM my_data
SELECT item_id || '.' || category_id as id, * FROM item_categories

-- the source database schema for the above example is CREATE TABLE item_categories(item_id uuid, category_id uuid, PRIMARY KEY(item_id, category_id));
```

<Warning>
Expand Down