Skip to content

Conversation

HeinrichvonStein
Copy link

@HeinrichvonStein HeinrichvonStein commented Jan 16, 2025

This PR adds a tutorial on to map sequential IDs to UUIDS.

);
```

The `uploadData` function in `SupabaseConnector.ts` needs to be updated to use the new `uuid` column in both tables.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkistner I'm not entirely sure if anything else is required here w.r.t explanation - it's pretty self explanatory but let me know if there's anything you want me to add

Co-authored-by: benitav <[email protected]>
</Step>
</Steps>

# Data Model
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have a strong opinion here, but I feel like we generally refer to "schema" as opposed to "data model" - so might want to be consistent (though I did see another "data model" ref in the docs now, which we could update too)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update to schema as data model is technically not the correct term to use, but I feel like schema and data model have become synonymous

```
</CodeGroup>

With the data mode updated, we now need a method to synchronize and map the `list_id` and `list_uuid` in the `todos` table, with the `id` and `uuid` columns in the `lists` table.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "data mode". should update to schema or data model based on decision above


# Introduction
When auto-incrementing / sequential IDs are used on the backend database, the ID can only be generated on the backend database, and not on the client while offline.
To handle this, you can use a secondary UUID on the client, then map them to a sequential ID when performing an update on the backend database.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"when performing an update on the backend database" - can we maybe make this clearer by saying "when uploading the record to the backend database" - or is that not technically correct? the current wording makes me think this mapping happens on any update to the backend database

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply 1:

when performing an update on the backend database"

That actually comes from our existing docs (I just updated server to backend database):
image

Reply 2:

the current wording makes me think this mapping happens on any update to the backend database

I guess there is some level of ambiguity here since the mapping will only occur when either FK columns are updated and not when "any" update occurs.


# Data Model

In order to map the UUID to the integer ID, we need to update the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it would be good to mention it's the backend/remote schema/data model specifically, since it doesn't look like we're updating anything on the client-side schema (yet)

Copy link
Author

@HeinrichvonStein HeinrichvonStein Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We update the client-side schema here.

Edit: Now that I think about it, the Schema section will only refer to the backend schema and not any client-side changes, so I can rename it to Backend Schema?


<CodeGroup>
```sql data model {3, 13, 21, 26}
create table public.lists (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be create statements? We're saying "update" above, so that's why I'm a bit confused.

HeinrichvonStein and others added 3 commits January 16, 2025 15:38
Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this.

@michaelbarnes michaelbarnes marked this pull request as ready for review January 16, 2025 18:17
@michaelbarnes
Copy link
Contributor

Did a once over and LGTM.

@michaelbarnes michaelbarnes merged commit 8c65ec7 into docs Jan 16, 2025
1 check passed
@michaelbarnes michaelbarnes deleted the tutorial/map-local-uuid branch January 16, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants