Viewing Records in the Truth Database

After the schema and client are registered correctly, your client is ready to sync its first records. Whether you use the low-level APIs, Core Data sync, or a sync session driver to sync, the sync process is the same. First your client negotiates a sync mode, then it pushes and pulls changes, and then it finishes or cancels the sync session.

Your client can request a sync mode, but the actual mode used is negotiated with the sync engine because it depends on the state of the sync engine and whether there are any other clients syncing the same entities. The sync mode that the sync engine expects to use is displayed in the Will Sync column when viewing the sync state as described in Viewing Sync Session State. For example, the sync engine expects to fast sync the Note entity the next time SimpleStickies syncs. This mode can change if, for example, the user requests a refresh sync as described in Testing Sync Modes.

In most cases, your client fast syncs by just pushing and pulling the changes since the last sync. After it does this, you can use Syncrospector to verify if the changes were applied correctly to the truth database.

Download the SimpleStickies sample code projects to follow along in this chapter.

Viewing Record Properties

You can check to see whether your records are pushed by examining the contents of the truth database. Of course, you’ll need to run your client, create some records, and sync them first.

If you are using your own client, add some records and sync them. Otherwise, add a few Note records using SimpleStickies as follows:

  1. Launch SimpleStickies and click the Add button below the table.

  2. Select a note record in the table, and set a few properties of the note records in the detail interface—for example, enter some text in the Text field, and change the color of each note record, as shown in Figure 4-1.

    Figure 4-1  Modify records
  3. Choose Sync from the File menu to save a local copy of the records and push them to the sync engine.

  4. If a Sync Alert dialog appears asking whether you would like to sync StickiesWithCoreData changes too, click Sync Stickies.

Then check to see if the records were pushed to the sync engine as follows:

  1. Using Syncrospector, choose Truth from the left-side pop-up menu.

  2. Click Reload if Syncrospector was running when you synced and the table is empty.

  3. Display the Note entities by entering com.mycompany.stickies.Note in the search field.

    The records you created should appear in the table.

  4. Select a record and click Properties in the detail view to see whether the property values are correct, as shown in Figure 4-2.

    Figure 4-2  Displaying record properties

Viewing Client States

The truth database keeps track of the state of each record per client that synced it. Most notably, each client has a different local record identifier for each record it syncs. When you sync records for the first time, you can use the local record identifiers provided by the sync engine or optionally generate your own local identifiers. Local record identifiers need to be unique for the lifetime of the record. Read Managing Your Sync Session and Changing Record Identifiers to learn more about assigning local record identifiers.

To view the different clients that synced a record, follow the steps in Viewing Record Properties and click Client States. Note that the truth database uses a global record identifier that is different from the SimpleStickies local record identifier shown in Figure 4-3.

Figure 4-3  Displaying record sync states

The History pane is described in Viewing the Call History.