Couchbase Developer study materials
Couchbase Developer study resources

Couchbase Developer: Couchbase Mobile and Edge Development

Couchbase Developer · Work through your exam, one topic at a time.

All guide sections

Couchbase Mobile and Edge Development

The Couchbase Mobile and Edge Development domain tests offline-first application design with Couchbase Lite on the device and Sync Gateway as the synchronization and access-control tier. Expect questions on replication modes, channels, conflict handling, authentication, and on-device querying.

Components and data flow

Couchbase Lite is an embedded JSON document database for iOS, Android, .NET, and Java. Sync Gateway synchronizes between Couchbase Lite and Couchbase Server. The device can read and write locally while offline; replication pushes local changes and pulls remote changes when connectivity returns. Replication can be one-shot or continuous, and direction can be push, pull, or both.

Channels and the sync function

Sync Gateway uses channels to decide which documents a user can pull. The sync function runs on every document write and assigns channels, validates content, and can reject writes. A user or role is granted access to channels; documents without a matching channel are not replicated to that user. Design channel names around access boundaries, not around UI screens.

Conflicts and revisions

Couchbase Lite documents have revision IDs and a revision tree. If two devices edit the same document offline, Sync Gateway may retain both branches as a conflict. The default resolver picks a winner deterministically, but production apps should define a custom conflict resolver with business rules. Delta sync reduces bandwidth by sending only changed parts of a document when supported.

Security and on-device queries

Sync Gateway supports basic authentication, session cookies, JWT, and client certificates. Access control is enforced during replication, not only in the UI. Couchbase Lite provides an on-device query API with local indexes; it is not the full server-side SQL++ engine, so queries must be designed for the device's resources.

Worked example

A document contains "owner":"alice". The sync function assigns channel(doc.owner) and rejects documents without an owner. Alice authenticates and pulls; Sync Gateway sends only documents in the alice channel. If Bob edits the same document on another device while Alice is offline, both revisions reach Sync Gateway and a conflict is recorded. A custom resolver that merges fields or applies a timestamp rule resolves it before the next pull.

Traps

Assuming server-side SQL++ features are available on Couchbase Lite leads to unsupported queries. Forgetting channel assignment in the sync function makes documents invisible after replication. Continuous replication drains battery and bandwidth if used without need. Ignoring conflict resolution leaves divergent data. Treating UI restrictions as security ignores Sync Gateway's channel-based access control.