Overview

The general approach is as follows:

  1. Define how many priority types you want - typically only two are needed: “high priority” and “the rest”
  2. Create a sync bucket for each priority type
  3. Use client parameters to control which priorities you want the client to sync

Example

Suppose we have two tables: lists and todos (as per the standard todolist demo app schema). Further, suppose we want the sync priority to behave as follows:

  1. First, sync all the user’s lists, enabling us to render the initial screen in the app
  2. Then, sync the user’s todos

Below are the sync rules that will enable this:

bucket_definitions:
  # always sync high priority tables (first), in this case the user's lists
  high_priority:
    parameters: select id as list_id from lists where owner_id = token_parameters.user_id
    data:
        - select * from lists where id = bucket.list_id
  # sync any remaining tables, in this case todo items
  remaining:
    parameters: select id as list_id from lists where owner_id = token_parameters.user_id and (request.parameters() ->> 'remaining_tables' = true)
    data: 
        - select * from todos where list_id = bucket.list_id

It is recommended to set Client Parameters in the Diagnostics App to verify functionality at this point:

If everything checks out, you can then proceed to implement the client parameter switching accordingly in your app.