{"id":7744,"date":"2019-10-16T13:14:44","date_gmt":"2019-10-16T20:14:44","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=7744"},"modified":"2025-06-13T20:52:21","modified_gmt":"2025-06-14T03:52:21","slug":"best-practices-couchbase-mobile-database-sync-part2","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/","title":{"rendered":"Best Practices and Patterns with Couchbase Mobile &#8211; Part 2"},"content":{"rendered":"<p><a href=\"https:\/\/www.couchbase.com\/products\/mobile\">Couchbase Mobile<\/a> enables a wide range of offline-first use cases of varying degrees of scale and complexity. In an earlier <a href=\"https:\/\/www.couchbase.com\/blog\/best-practices-common-patterns-couchbase-mobile-part1\/\">post<\/a>, I discussed common patterns while using Couchbase Lite as embedded NoSQL data store within your apps. Those patterns focused on local data storage. In this blog post, we discuss a few common patterns and best practices as it relates to syncing data with the <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/2.6\/introduction.html\">Sync Gateway<\/a>. This post assumes that you are familiar with the fundamentals of Couchbase Mobile. If you need a primer, check out the docs on <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/introduction.html\">Couchbase Lite<\/a> and <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/2.6\/index.html\">Sync Gateway<\/a>.<\/p>\n<h3 id=\"pattern1:keepingthedataup-to-syncwhileappisinthebackground\">Pattern 1: Keeping the data up-to-sync while app is in the background<\/h3>\n<figure><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/09\/background-sync-e1567893400788.png\" alt=\"couchbase mobile app background\" \/><\/figure>\n<p>Backgrounding support on mobile apps varies drastically by platform. In fact, on certain platforms such as Android, the concept of \u201cbackgrounded apps\u201d is quite nebulous\/complicated. So how you would sync data while your app is in the background is very much platform-dependent. You can find a discussion on how Couchbase Lite reacts to app life cycle on <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-status-and-app-life-cycle\">iOS<\/a>, <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/java.html#replication-status-and-app-life-cycle\">Android<\/a> and <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/csharp.html#replication-status-and-app-life-cycle\">Windows<\/a> in our documentation.<\/p>\n<ul>\n<li><strong>Use Case<\/strong><\/li>\n<\/ul>\n<p>By keeping the data up-to-date when not in active use (or in the foreground), apps can improve end-user experience by reducing start up time on subsequent launches.<\/p>\n<ul>\n<li><strong>Approach<\/strong>\n<ul>\n<li>It should be noted that there is no guarantee that your app will be permitted to run in the background. That is typically a system level or a user level decision.<\/li>\n<li>How an app handles background sync is platform dependent<\/li>\n<li>It is generally recommended that when possible, your app react to suitable app life cycle events and close the replicator before transitioning to the background<\/li>\n<li><strong>iOS<\/strong>\n<ul>\n<li>Continuous replications is transitioned to offline mode when app is pushed to background<\/li>\n<li>Use <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/NetworkingInternet\/Conceptual\/RemoteNotificationsPG\/APNSOverview.html#\/\/apple_ref\/doc\/uid\/TP40008194-CH8-SW1\">Apple Push Notification Sevice (APNS)<\/a> to send a <a href=\"https:\/\/developer.apple.com\/documentation\/usernotifications\/setting_up_a_remote_notification_server\/pushing_updates_to_your_app_silently\">silent notification<\/a> to wake up the app while in the background or use <a href=\"https:\/\/developer.apple.com\/documentation\/uikit\/core_app\/managing_your_app_s_life_cycle\/preparing_your_app_to_run_in_the_background\/updating_your_app_with_background_app_refresh\">Background App Refresh<\/a> to let the system opportunistically wake up the app<\/li>\n<li>When app is woken up in the background, do a one-shot replication to sync data<\/li>\n<li>More on background support on iOS in this <a href=\"https:\/\/www.couchbase.com\/blog\/background-sync-couchbase-mobile-ios\/\">blog post<\/a>.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Android<\/strong>\n<ul>\n<li>There are couple of options available if apps have to be run tasks in the background\n<ul>\n<li>Use <a href=\"https:\/\/developer.android.com\/guide\/components\/services\">Foreground Service<\/a> for long running replications in the background<\/li>\n<li>Use <a href=\"https:\/\/developer.android.com\/topic\/libraries\/architecture\/workmanager\">Work Manager<\/a> to schedule one-shot replications to run asynchronously in the background or use Remote <a href=\"https:\/\/firebase.google.com\/docs\/cloud-messaging\/\">Firebase Cloud Messaging(FCM)<\/a> to kick off a work request to run a one-shot replication<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>UWP<\/strong>\n<ul>\n<li>Continuous replications are not transitioned to offline mode when an app is pushed to background. It is recommended however that apps close replicator when they transition to background<\/li>\n<li>Use <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/design\/shell\/tiles-and-notifications\/raw-notification-overview\">raw notifications<\/a> sent via <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/design\/shell\/tiles-and-notifications\/windows-push-notification-services--wns--overview\">Windows Push Notification Service(WPNS)<\/a> to wake up the app while in the background<\/li>\n<li>When app is woken up in the background, schedule a background task to do a one-shot replication to sync data<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 id=\"pattern2:purgeafterpush\">Pattern 2: Purge after Push<\/h3>\n<figure><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/09\/purge-after-push-2-e1567895071699.png\" alt=\"clear local database after syncing data\" \/><\/figure>\n<p>Couchbase Lite supports the ability for apps to be notified on the replication status of a document or set of documents via <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-events\">Replication Eventing<\/a> capability. Apps can leverage this capability to take appropriate action on the document depending on the status such as purging the document.<\/p>\n<ul>\n<li><strong>Use Case<\/strong><\/li>\n<\/ul>\n<p>It may be desirable to remove documents from local client store after it\u2019s been synced over to the server for governance compliance reasons or to avoid local database bloat.<\/p>\n<ul>\n<li><strong>Approach<\/strong>\n<ul>\n<li>Register <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-events\">Replication Event<\/a> observer on Replicator<\/li>\n<li>On receiving <code>onPushed<\/code> event on document(s), invoke <a href=\"https:\/\/docs.couchbase.com\/mobile\/2.6.0\/couchbase-lite-swift\/Classes\/Database.html#\/s:18CouchbaseLiteSwift8DatabaseC13purgeDocument6withIDySS_tKF\">purge()<\/a> API to get rid of document. Purged documents are not synced.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 id=\"pattern3:enforcingserversidedocumentlifespanondisconnectedclients\">Pattern 3: Enforcing server side document lifespan on disconnected clients<\/h3>\n<figure><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/09\/docexpiration-e1567913583132.png\" alt=\"Set local TTL on documents\" \/><\/figure>\n<p>Couchbase Lite supports the ability for apps to set expiration dates on local documents via <a href=\"https:\/\/docs.couchbase.com\/mobile\/2.6.0\/couchbase-lite-swift\/Classes\/Database.html#\/s:18CouchbaseLiteSwift8DatabaseC21setDocumentExpiration6withID10expirationySS_10Foundation4DateVSgtKF\">Expiration Date<\/a> feature. Apps can leverage this capability to locally expire a document on Couchbase Lite regardless of connectivity to the server.<\/p>\n<ul>\n<li><strong>Use Case<\/strong><\/li>\n<\/ul>\n<p>Documents created on the server may be associated with a TTL or expiration date that dictates when the document has to be purged from the system (clients and server). When there is network connectivity, documents deleted on the server side will be synced over to the client side so they are deleted on client side as well. However, it is likely that clients are offline when documents expire on the server and it may be important that these documents be removed from the clients in a timely fashion.<\/p>\n<ul>\n<li><strong>Approach<\/strong>\n<ul>\n<li>Model your documents to include a user-defined property that specifies the UTC time when document expires. Lets call it <em>validUntil<\/em>.<\/li>\n<li>Register <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-events\">Replication Event<\/a> observer on client Replicator<\/li>\n<li>On receiving <code>Pull<\/code> event on document(s), use the <em>validUntil<\/em> value to set the TTL on documents using the <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#document-expiration\">setExpirationDate()<\/a> API<\/li>\n<li>When documents expire on the client, they are automatically purged from the client regardless of network connectivity. The purged documents are not synced.<\/li>\n<li>On the server side, the documents can be purged independently<\/li>\n<li><strong>Caveat<\/strong> : If the expirationDate(as defined by <em>validUntil<\/em> property)is updated while the clients are offline, then the clients will not be notified of this change. So it is possible that documents may get prematurely purged on clients when they are offline. So this approach is safe as long as the lifespan of document does not change after creation. We will discuss another approach to handle such cases.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 id=\"pattern4:controllingwhenandwhatdocumentsgetsyncedtoserver\">Pattern 4: Controlling when and what documents get synced to server<\/h3>\n<figure><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/10\/replication-filter-2.png\" alt=\"controlling documents that get pushed to server\" \/><\/figure>\n<p>Couchbase Lite supports the ability for apps to set fine-grained <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-filters\">filters<\/a> on the replicator that determines what documents get pushed to the server. This capability can be leveraged to control when and what documents get synced to the server.<\/p>\n<ul>\n<li><strong>Use Case<\/strong><\/li>\n<\/ul>\n<p>In an earlier <a href=\"https:\/\/www.couchbase.com\/blog\/best-practices-common-patterns-couchbase-mobile-part1\/\">blog<\/a>, we discussed how a separate instance of a database can be used for holding local-only data. While that pattern works when you need strict data segregation and if cross-database join queries are not required, there are use cases when you would want fine-grained control over <em>when<\/em> the local changes are to be synced. You could also use this pattern as an alternative to the pre-built database pattern in order to enforce that documents are local-only( i.e. never synced).<\/p>\n<ul>\n<li><strong>Approach<\/strong>\n<ul>\n<li>Model your documents to include a user-defined <em>\u201cstatus\u201d<\/em> property that controls the business workflow. For instance, use a value of <em>\u201cin-progress\u201d<\/em> to indicate when changes are not ready to be synced and a status value of <em>\u201ccommitted\u201d<\/em> when changes need to be pushed up. If you need to make documents local-only, then use a user-defined <em>\u201cscope\u201d<\/em> property with a value of <em>\u201clocal\u201d<\/em> to indicate that documents are not to be syned<\/li>\n<li>Configure suitable <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-filters\">Replication Filter<\/a> function on the replicator. The filter should inspect the document property (as defined above) to determine if a document needs to be synced or not<\/li>\n<li>Every time there are changes ready to be pushed, the filter function is applied by the Couchbase Lite replicator and documents are synced only if the filter criteria is satisfied.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 id=\"pattern5:controllingthepriorityorderofinitialsetofdocumentssyncedtotheclient\">Pattern 5: Controlling the priority order of initial set of documents synced to the client<\/h3>\n<figure><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/09\/channel-assignment-e1568069916997.png\" alt=\"sync gateway channel priority\" \/><\/figure>\n<p>Sync Gateway <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/2.6\/data-routing.html\">channels<\/a> allow apps to segregate data based on type, purpose, access control permissions etc. This can be leveraged to segregate data based on priority.<\/p>\n<ul>\n<li><strong>Use Case<\/strong><\/li>\n<\/ul>\n<p>The ability to prioritize the documents received by clients would ensure that the clients can get up and going with the most relevant document changes as soon as it has pulled them without having to waiting for the rest of the documents to sync. The remaining, lower priority document changes are pulled down later. This reduces the app response times on initial startup.<\/p>\n<ul>\n<li><strong>Approach<\/strong>\n<ul>\n<li>Assign documents to different channels based on priority. For instance, you could have documents assigned to \u201clow\u201d, \u201cmedium\u201d or \u201chigh\u201d priority channels.<\/li>\n<li>On client side, on initial launch, do a one-shot pull replication of highest priority channel by specifying the <a href=\"https:\/\/docs.couchbase.com\/mobile\/2.6.0\/couchbase-lite-swift\/Classes\/ReplicatorConfiguration.html#\/s:18CouchbaseLiteSwift23ReplicatorConfigurationC8channelsSaySSGSgvp\">channels<\/a> filter. Once the sync of the documents in channel <a href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/2.6\/swift.html#replication-status\">completes<\/a>, the app can kick off another replication for the remaining channels.<\/li>\n<li>You can also set up a continuous replicator for highest priority channel and pull the remaining channels only on-demand using one-shot replication. This will ensure that the highest priority channel is kept up-to-sync in real time.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2 id=\"whatnext\">What Next<\/h2>\n<p>In this post, we covered a few common usage patterns in Couchbase Lite as it related to syncing data to and from the Sync Gateway and Couchbase server. We will continue to publish posts describing other tips and recommendations for solving common use cases.<br \/>\nIf\u00a0you have questions or feedback, please leave a comment below or feel free to reach out to me on\u00a0<a href=\"https:\/\/twitter.com\/rajagp\">Twitter<\/a>\u00a0or <a href=\"mailto:\/\/priya.rajagopal@couchbase.com\">email<\/a> me . \u00a0The\u00a0<a href=\"https:\/\/www.couchbase.com\/forums\/\">Couchbase Forums<\/a> are another good place to reach out with\u00a0questions.<\/p>\n<h2 id=\"acknowledgments\">Acknowledgments<\/h2>\n<p>I would like to acknowledge the contributions of the Couchbase Lite and Sync Gateway development team, specifically <a href=\"https:\/\/github.com\/adamcfraser\">Adam Fraser<\/a> and <a href=\"https:\/\/github.com\/borrrden\">Jim Borden<\/a> for their review of the blog post.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Couchbase Mobile enables a wide range of offline-first use cases of varying degrees of scale and complexity. In an earlier post, I discussed common patterns while using Couchbase Lite as embedded NoSQL data store within your apps. Those patterns focused [&hellip;]<\/p>\n","protected":false},"author":1423,"featured_media":7748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[2370,1814,1815,7667,1810,2389,2366],"tags":[2004,2358,1572,1536,1725,2348,2349],"ppma_author":[8948],"class_list":["post-7744","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-application-design","category-best-practices-and-tutorials","category-couchbase-lite","category-couchbase-mobile","category-solutions","category-sync-gateway","tag-couchbase-mobile-2-0","tag-couchbase-mobile-2-x","tag-database","tag-ios","tag-nosql-database","tag-uwp","tag-xamarin"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Best Practices and Patterns with Couchbase Mobile - Part 2 - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"We discuss a few common patterns and best practices as it relates to storing and syncing data between mobile apps and cloud using Couchbase Mobile\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Best Practices and Patterns with Couchbase Mobile - Part 2\" \/>\n<meta property=\"og:description\" content=\"We discuss a few common patterns and best practices as it relates to storing and syncing data between mobile apps and cloud using Couchbase Mobile\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-16T20:14:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:52:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png\" \/>\n\t<meta property=\"og:image:width\" content=\"396\" \/>\n\t<meta property=\"og:image:height\" content=\"308\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Priya Rajagopal, Senior Director, Product Management\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rajagp\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Priya Rajagopal, Senior Director, Product Management\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\"},\"author\":{\"name\":\"Priya Rajagopal, Senior Director, Product Management\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c\"},\"headline\":\"Best Practices and Patterns with Couchbase Mobile &#8211; Part 2\",\"datePublished\":\"2019-10-16T20:14:44+00:00\",\"dateModified\":\"2025-06-14T03:52:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\"},\"wordCount\":1449,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png\",\"keywords\":[\"couchbase mobile 2.0\",\"couchbase mobile 2.x\",\"database\",\"ios\",\"NoSQL Database\",\"uwp\",\"xamarin\"],\"articleSection\":[\"Android\",\"Application Design\",\"Best Practices and Tutorials\",\"Couchbase Lite\",\"Couchbase Mobile\",\"Solutions\",\"Sync Gateway\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\",\"name\":\"Best Practices and Patterns with Couchbase Mobile - Part 2 - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png\",\"datePublished\":\"2019-10-16T20:14:44+00:00\",\"dateModified\":\"2025-06-14T03:52:21+00:00\",\"description\":\"We discuss a few common patterns and best practices as it relates to storing and syncing data between mobile apps and cloud using Couchbase Mobile\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png\",\"width\":396,\"height\":308,\"caption\":\"Couchbase Mobile Sync\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Best Practices and Patterns with Couchbase Mobile &#8211; Part 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c\",\"name\":\"Priya Rajagopal, Senior Director, Product Management\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4b50a54778b979d8c345b036ab138734\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g\",\"caption\":\"Priya Rajagopal, Senior Director, Product Management\"},\"description\":\"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.\",\"sameAs\":[\"https:\/\/x.com\/rajagp\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/priya-rajagopalcouchbase-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Best Practices and Patterns with Couchbase Mobile - Part 2 - The Couchbase Blog","description":"We discuss a few common patterns and best practices as it relates to storing and syncing data between mobile apps and cloud using Couchbase Mobile","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/","og_locale":"en_US","og_type":"article","og_title":"Best Practices and Patterns with Couchbase Mobile - Part 2","og_description":"We discuss a few common patterns and best practices as it relates to storing and syncing data between mobile apps and cloud using Couchbase Mobile","og_url":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/","og_site_name":"The Couchbase Blog","article_published_time":"2019-10-16T20:14:44+00:00","article_modified_time":"2025-06-14T03:52:21+00:00","og_image":[{"width":396,"height":308,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png","type":"image\/png"}],"author":"Priya Rajagopal, Senior Director, Product Management","twitter_card":"summary_large_image","twitter_creator":"@rajagp","twitter_misc":{"Written by":"Priya Rajagopal, Senior Director, Product Management","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/"},"author":{"name":"Priya Rajagopal, Senior Director, Product Management","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c"},"headline":"Best Practices and Patterns with Couchbase Mobile &#8211; Part 2","datePublished":"2019-10-16T20:14:44+00:00","dateModified":"2025-06-14T03:52:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/"},"wordCount":1449,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png","keywords":["couchbase mobile 2.0","couchbase mobile 2.x","database","ios","NoSQL Database","uwp","xamarin"],"articleSection":["Android","Application Design","Best Practices and Tutorials","Couchbase Lite","Couchbase Mobile","Solutions","Sync Gateway"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/","url":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/","name":"Best Practices and Patterns with Couchbase Mobile - Part 2 - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png","datePublished":"2019-10-16T20:14:44+00:00","dateModified":"2025-06-14T03:52:21+00:00","description":"We discuss a few common patterns and best practices as it relates to storing and syncing data between mobile apps and cloud using Couchbase Mobile","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/10\/Automatic-Sync.png","width":396,"height":308,"caption":"Couchbase Mobile Sync"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/best-practices-couchbase-mobile-database-sync-part2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Best Practices and Patterns with Couchbase Mobile &#8211; Part 2"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c","name":"Priya Rajagopal, Senior Director, Product Management","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/4b50a54778b979d8c345b036ab138734","url":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","caption":"Priya Rajagopal, Senior Director, Product Management"},"description":"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.","sameAs":["https:\/\/x.com\/rajagp"],"url":"https:\/\/www.couchbase.com\/blog\/author\/priya-rajagopalcouchbase-com\/"}]}},"authors":[{"term_id":8948,"user_id":1423,"is_guest":0,"slug":"priya-rajagopalcouchbase-com","display_name":"Priya Rajagopal, Senior Director, Product Management","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","author_category":"","last_name":"Rajagopal, Senior Director, Product Management","first_name":"Priya","job_title":"","user_url":"","description":"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/7744","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/1423"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=7744"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/7744\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/7748"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=7744"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=7744"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=7744"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=7744"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}