On the client, PowerSync only supports a single primary key column called id
, of type text
.
uuid()
to generate a random UUID (v4) on the client.
To use a different column/field from the server-side database as the record ID on the client, use a column/field alias in your Sync Rules:
_id
as the name of the ID field in collections. Therefore, PowerSync requires using SELECT _id as id
in the data queries when using MongoDB as the backend source database.sequence
type in Postgres), the issue is that the ID can only be generated on the server, and not on the client while offline. If this must be used, there are some options, depending on the use case.
id
field, then generate a new ID when the server receives it.