Update sync function

Updates the sync function for the database. The sync function controls channel routing and access grants for documents.