This feature is available in SDK version 4.12.0 and later.
This feature works fully with with DQL Strict Mode disabled. DQL_STRICT_MODE=falseRead more about STRICT MODE and upcoming v5 behavior
The system:data_sync_info collection provides real-time information about synchronization status between your device and other peers in the Ditto mesh network.

What You Can Monitor

  • Connection status with peers and cloud servers
  • Sync progress using commit IDs
  • Last update timing from each peer

Document Structure

Each document in system:data_sync_info represents one peer connection:
{
  "_id": "peer-123",
  "is_ditto_server": true,
  "documents": {
    "sync_session_status": "Connected",
    "synced_up_to_local_commit_id": 1500,
    "last_update_received_time": 1703123456
  }
}

Key Fields

  • _id - Unique peer identifier
  • is_ditto_server - true for cloud servers, false for other devices
  • sync_session_status - "Connected", "Not Connected", or "Disabled"
  • synced_up_to_local_commit_id - Latest commit ID synced to this peer
  • last_update_received_time - Unix timestamp of last data received

Basic Queries

The examples in this document assume DQL Strict Mode is disabled.If DQL Strict Mode is enabled the collection definition must be provided.COLLECTION system:data_sync_info (documents MAP)Read more about STRICT MODE and upcoming v5 behavior

Get All Peers

SELECT * FROM system:data_sync_info

Get Only Cloud Servers

SELECT * FROM system:data_sync_info WHERE is_ditto_server = true

Get Connected Peers Only

SELECT * FROM system:data_sync_info WHERE documents.sync_session_status = 'Connected'

Get Specific Fields

SELECT _id, documents.sync_session_status, documents.synced_up_to_local_commit_id 
FROM system:data_sync_info

Example in Code

// Get all sync info
let result = try await ditto.store.execute(
  query: "SELECT * FROM system:data_sync_info"
)

result.items.forEach { item in
  let peer = item.value
  let status = (peer["documents"] as? [String: Any])?["sync_session_status"] as? String ?? "Unknown"
  print("Peer \(peer["_id"] ?? ""): \(status)")
}

Observing Changes

Observers on system:data_sync_info result in the callback triggering every 500ms even when the result remains the same. This frequency can be configured using the live_query_system_collection_refresh_interval system parameter.
Use registerObserver to monitor sync status changes in real-time:
let observer = ditto.store.registerObserver(
  query: "SELECT * FROM system:data_sync_info"
) { result in
  result.items.forEach { item in
    let peer = item.value
    let status = (peer["documents"] as? [String: Any])?["sync_session_status"] as? String ?? "Unknown"
    print("Peer \(peer["_id"] ?? ""): \(status)")
  }
}

Using Commit IDs

Every data modification returns a commit ID that you can use to track sync progress:
// Every mutation returns a commit ID
let result = try await ditto.store.execute(
  query: "UPDATE cars SET color = 'blue' WHERE _id = '123'"
)
print("Commit ID: \(result.commitID ?? -1)")
Compare this commit ID with synced_up_to_local_commit_id to see if a peer has received your change.

Important Notes

Sync status information is local-only and never synchronizes between peers. Each peer maintains its own view of sync status.
  • Commit IDs are monotonic (always increasing) but not necessarily sequential
  • Multiple cloud servers may appear due to load balancing or failover
  • Local-only data - this collection exists only on your device
  • Minimal performance impact - observing sync status is lightweight

Supported APIs

API/FeatureIndex Support
execute SDK API✅ Supported
registerObserver SDK API✅ Supported
registerSubscription SDK API❌ Not Supported
Big Peer HTTP API❌ Not Supported
SDKs with in-memory storage (e.g. web browser)❌ Not Supported