Your backend application needs to expose an API endpoint to apply write operations to your backend database that are received from the PowerSync Client SDK.
uploadData()
function in the PowerSyncBackendConnector
in your client-side app. See Integrate with your Backend in the Client-Side Setup section for details.uploadData()
function as you wish, you have full control over how to structure your backend application API to accept write operations from the client. For example, you can have:
uploadData()
, you can call the respective endpoints as needed.Why must my write endpoint be synchronous?
Operation | Purpose | Contents | SQLite Statement |
---|---|---|---|
PUT | Create new row | Contains the value for each non-null column | Generated by INSERT statements. |
PATCH | Update existing row | Contains the row id , and value of each changed column. | Generated by UPDATE statements. |
DELETE | Delete existing row | Contains the row id | Generated by DELETE statements. |
5xx
) only when the write operations cannot be applied due to a temporary error (e.g. backend database not available). In this scenario, the PowerSync Client SDK can retry uploading the write operation and it should succeed at a later time.4xx
), since it will block the PowerSync client’s upload queue. Instead, it is best to return a 2xx
response, and if needed, propagate the validation or other error message(s) back to the client, for example by:
2xx
response.