{"id":10281,"date":"2023-06-23T01:43:43","date_gmt":"2023-06-23T08:43:43","guid":{"rendered":"https:\/\/www.couchbase.com\/developers\/tutorials\/quickstart-android-java-sync\/"},"modified":"2023-06-23T01:43:43","modified_gmt":"2023-06-23T08:43:43","slug":"quickstart-android-java-sync","status":"publish","type":"tutorials","link":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/","title":{"rendered":"Quickstart in Couchbase Lite Data Sync with Android and Java"},"content":{"rendered":"\n<h3 id=\"h-introduction\" class=\"wp-block-heading\">Introduction<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an Internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile uses a websocket based <a href=\"https:\/\/blog.couchbase.com\/data-replication-couchbase-mobile\/\" target=\"blank\" rel=\"noopen noreferrer\">replication protocol<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The core functions of the Sync Gateway include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Data Synchronization across devices and the cloud<\/li>\n\n\n<li>Authorization &amp; Access Control<\/li>\n\n\n<li>Data Validation<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial will demonstrate how to &#8211;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Setup a basic Couchbase Sync Gateway configuration to sync content between multiple Couchbase Lite enabled clients. We will will cover the basics of the <a href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/configuration-overview.html\" target=\"_blank\" rel=\"noopener noreferrer\">Sync Gateway Configuration<\/a>.<\/li>\n\n\n<li>Configure your Sync Gateway to enforce data routing, access control and authorization. We will cover the basics of <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/sync-function.html\">Sync Function API<\/a>.<\/li>\n\n\n<li>Configure your Couchbase Lite clients for replication with the Sync Gateway<\/li>\n\n\n<li>Use &#8220;Live Queries&#8221; or Query events within your Couchbase Lite clients to be asyncronously notified of changes.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">We will be using a Android Java App as an example of a Couchbase Lite enabled client.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">You can learn more about the Sync Gateway here in the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/index.html\">Sync Gateway Documentation<\/a>.<\/p>\n<\/blockquote>\n\n\n\n<h3 id=\"h-prerequisites\" class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial assumes familiarity with building <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/www.android.com\/\">Android<\/a> apps using <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/openjdk.java.net\/\">Java<\/a> and with the basics of Couchbase Lite.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>If you are unfamiliar with the basics of Couchbase Lite, it is recommended that you walk through the following tutorials<\/p>\n<ul>\n<li>Fundamentals of using Couchbase Lite as a standalone database &#8211; see <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.couchbase.com\/tutorial-quickstart-android-java-basic\">Quickstart in Couchbase Lite with Android and Java<\/a><\/li>\n<li>Query Basics with a prebuilt version of Couchbase Lite database &#8211; see <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.couchbase.com\/tutorial-quickstart-android-java-query\">Quickstart in Couchbase Lite Query with Android and Java<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.android.com\/studio\">Android Studio 3.4 or above<\/a><\/p>\n<\/li>\n\n\n<li>\n<p>Android SDK installed and setup (&gt; v.28.0.0)<\/p>\n<\/li>\n\n\n<li>\n<p>Android Build Tools (&gt; v.28.0.0)<\/p>\n<\/li>\n\n\n<li>\n<p>Android device or emulator running API level 21 or above<\/p>\n<\/li>\n\n\n<li>\n<p>JDK 8 (now embedded into Android Studio 4+)<\/p>\n<\/li>\n\n\n<li>\n<p>curl HTTP client<\/p>\n<ul>\n<li>\n<p>You could use any HTTP client of your choice. But we will use <em>curl<\/em> in our tutorial. Download latest version from <a href=\"https:\/\/curl.haxx.se\/download.html\">curl website<\/a>.  MacOS Package manager users can use <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/brew.sh\/\">homebrew<\/a>.  Windows Package Manager users can use <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/package-manager\/winget\/\">winget<\/a>.<\/p>\n<\/li>\n<li>\n<p>Docker<\/p>\n<ul>\n<li>We will be using Docker to run images of both Couchbase Server and the Sync Gateway \u2014 to download Docker, or for more information, see: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.docker.com\/get-docker\/\">Get Docker<\/a>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n<\/ul>\n\n\n\n<h3 id=\"h-system-overview\" class=\"wp-block-heading\">System Overview<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We will be working with a simple &#8220;User Profile&#8221; app which we introduced in the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.couchbase.com\/tutorial-quickstart-android-java-basic\">Quickstart in Couchbase Lite with Android and Java<\/a> tutorial and extended in the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.couchbase.com\/tutorial-quickstart-android-java-query\">Quickstart in Couchbase Lite Query with Android and Java<\/a> tutorial.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will be extending that app to support data sync.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The app does the following<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>Allows users to log in and create or update his\/her user profile information. The user profile view is <strong><em>automatically updated<\/em><\/strong> every time the profile information changes in the underlying database.<\/p>\n<\/li>\n\n\n<li>\n<p>The user profile information is synced with a remote Sync Gateway which then syncs it to other devices (subject to access control and routing configurations specified in the <code>sync function<\/code>).<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/userprofile_app_overview.gif\" alt=\"App with Sync\"><\/p>\n\n\n\n<h3 id=\"h-app-installation\" class=\"wp-block-heading\">App Installation<\/h3>\n\n\n\n<h4 id=\"h-fetching-app-source-code\" class=\"wp-block-heading\">Fetching App Source Code<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">To clone the project from GitHub, type the following command in your terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>git clone https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-sync\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-installing-couchbase-lite\" class=\"wp-block-heading\">Installing Couchbase Lite<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The User Profile Standalone Demo app already contains the appropriate additions for downloading and utilizing the Java Android Couchbase Lite dependency module.  However, in the future, to include Couchbase Lite support within an Andorid app add the following within <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-standalone\/blob\/main\/src\/build.gradle\">src\/build.gradle<\/a><\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>allprojects {\n    repositories {\n        ...\n\n        maven {\n            url &quot;https:\/\/mobile.maven.couchbase.com\/maven2\/dev\/&quot;\n        }\n    }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then add the following to the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-query\/blob\/main\/src\/app\/build.gradle\">app\/build.gradle<\/a> file.<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>dependencies {\n    ...\n\n    implementation &#039;com.couchbase.lite:couchbase-lite-android-ee:3.0.0&#039;\n}\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-try-it-out\" class=\"wp-block-heading\">Try it out<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open build.gradle using Android Studio.<\/li>\n\n\n<li>Build and run the project.<\/li>\n\n\n<li>Verify that you see the login screen.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/user_profile_login.png\" alt=\"User Profile Login Screen Image\"><\/p>\n\n\n\n<h3 id=\"h-sample-app-architecture\" class=\"wp-block-heading\">Sample App Architecture<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The sample app follows the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/en.wikipedia.org\/wiki\/Model%E2%80%93view%E2%80%93presenter\">MVP pattern<\/a>, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/mvp_architecture.png\" alt=\"MVP Architecture\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the Android Studio project, the code is structured by feature. You can select the Android option in the left navigator to view the files by package.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/mvp_as.png\" alt=\"MVP Android Studio\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each package contains 3 different files:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p><strong>Activity<\/strong>: This is where all the view logic resides.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Presenter<\/strong>: This is where all the business logic resides to fetch and persist data to a web service or the embedded Couchbase Lite database.<\/p>\n<\/li>\n\n\n<li>\n<p><strong>Contract<\/strong>: An interface that the <code>Presenter<\/code> and <code>Activity<\/code> implement.<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/mvp_package.png\" alt=\"MVP Package\"><\/p>\n\n\n\n<h3 id=\"h-data-model\" class=\"wp-block-heading\">Data Model<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you fhave followed along the tutorial on link:[Query Basics], you can skip this section and proceed to the <a href=\"#backend-installation\">Backend Installation<\/a> section since we have not made any changes to the Data model for this tutorial.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Couchbase Lite is a JSON Document Store. A Document is a logical collection of named fields and values.  The values are any valid JSON types. In addition to the standard JSON types, Couchbase Lite supports some special types like <code>Date<\/code> and <code>Blob<\/code>.\nWhile it is not required or enforced, it is a recommended practice to include a <em>&#8220;type&#8221;<\/em> property that can serve as a namespace for related.<\/p>\n\n\n\n<h4 id=\"h-the-user-profile-document\" class=\"wp-block-heading\">The User Profile Document<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The app deals with a single Document with a <em>&#8220;type&#8221;<\/em> property of <em>&#8220;user&#8221;<\/em>.  The document ID is of the form <strong><em>&#8220;user::<a href=\"mailto:demo@example.com\">demo@example.com<\/a>&#8220;<\/em><\/strong>.\nAn example of a document would be<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n    &quot;type&quot;:&quot;user&quot;,\n    &quot;name&quot;:&quot;Jane Doe&quot;,\n    &quot;email&quot;:&quot;jame.doe@earth.org&quot;,\n    &quot;address&quot;:&quot;101 Main Street&quot;,\n    &quot;image&quot;:CBLBlob (image\/jpg),\n    &quot;university&quot;:&quot;Missouri State University&quot;\n}\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-userprofile-encoding\" class=\"wp-block-heading\">UserProfile Encoding<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">For this tutorial the <em>&#8220;user&#8221;<\/em> <code>Document<\/code> is first stored within an <code>Object<\/code> of type <code>Map&lt;String, Object&gt;<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>Map&lt;String, Object&gt; profile = new HashMap&lt;&gt;();\nprofile.put(&quot;name&quot;, nameInput.getText().toString());\nprofile.put(&quot;email&quot;, emailInput.getText().toString());\nprofile.put(&quot;address&quot;, addressInput.getText().toString());\nprofile.put(&quot;university&quot;, universityText.getText().toString());\nprofile.put(&quot;type&quot;, &quot;user&quot;);\nbyte[] imageViewBytes = getImageViewBytes();\n\nif (imageViewBytes != null) {\n    profile.put(&quot;imageData&quot;, new com.couchbase.lite.Blob(&quot;image\/jpeg&quot;, imageViewBytes));\n}\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-the-university-document\" class=\"wp-block-heading\">The University Document<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The app comes bundled with a collection of Documents of type <em>&#8220;university&#8221;<\/em>. Each <code>Document<\/code> represents a university.<\/p>\n\n\n\n<pre class=\"wp-block-code language-json\"><code>{\n    &quot;type&quot;:&quot;university&quot;,&quot;web_pages&quot;: [\n      &quot;http:\/\/www.missouristate.edu\/&quot;\n    ],\n    &quot;name&quot;: &quot;Missouri State University&quot;,\n    &quot;alpha_two_code&quot;: &quot;US&quot;,\n    &quot;state-province&quot;: MO,\n    &quot;domains&quot;: [\n      &quot;missouristate.edu&quot;\n    ],\n    &quot;country&quot;: &quot;United States&quot;\n}\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-university-record-encoding\" class=\"wp-block-heading\">University Record Encoding<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">When <em>&#8220;university&#8221;<\/em> <code>Document<\/code> is retrieved from the database it is stored within an <code>Object<\/code> of type <code>Map&lt;String, Object&gt;<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>Map&lt;String, Object&gt; properties = new HashMap&lt;&gt;()\nproperties.put(&quot;name&quot;, row.getDictionary(&quot;universities&quot;).getString(&quot;name&quot;));\nproperties.put(&quot;country&quot;, row.getDictionary(&quot;universities&quot;).getString(&quot;country&quot;));\nproperties.put(&quot;web_pages&quot;, row.getDictionary(&quot;universities&quot;).getArray(&quot;web_pages&quot;));]\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-backend-installation\" class=\"wp-block-heading\">Backend Installation<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We will install <a href=\"#couchbase-server\">Couchbase Server<\/a> and <a href=\"#sync-gateway\">Sync Gateway<\/a> using Docker.<\/p>\n\n\n\n<h4 id=\"h-prerequisites\" class=\"wp-block-heading\">Prerequisites<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You must have Docker installed on your laptop. For more on Docker \u2014 see: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.docker.com\/get-docker\/\">Get Docker<\/a>.<\/li>\n\n\n<li>On Windows, you may need admin privileges.<\/li>\n\n\n<li>Ensure that you have sufficient memory and cores allocated to docker. At Least 3GB of RAM is recommended.<\/li>\n\n<\/ul>\n\n\n\n<h4 id=\"h-docker-network\" class=\"wp-block-heading\">Docker Network<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Couchbase Server and Sync Gateway Server need to communicate with each other over the network.  A network bridge in docker allows network traffic between servers.  Create a docker network bridge named <strong>workshop<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker network ls\n\ndocker network create -d bridge workshop\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-couchbase-server\" class=\"wp-block-heading\">Couchbase Server<\/h4>\n\n\n\n<h5 id=\"h-install\" class=\"wp-block-heading\">Install<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">We have a custom docker image priyacouch\/couchbase-server-userprofile:7.0.0-dev of Couchbase Server, which creates an empty bucket named <strong>userprofile<\/strong> and an RBAC user <strong>admin<\/strong> with <strong>sync gateway<\/strong> role.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, you can follow the instructions in our documentation \u2014 see: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/get-started-prepare.html\">Get Started &#8211; Prepare<\/a>, to install Couchbase Server and configure it with the relevant bucket.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Optionally, remove any existing Docker container.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker stop cb-server &amp;&amp; docker rm cb-server\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start Couchbase Server in a Docker container<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker run -d --name cb-server \n--network workshop \n-p 8091-8094:8091-8094 -p 11210:11210 \npriyacouch\/couchbase-server-userprofile:7.0.0-dev\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-test-server-installation\" class=\"wp-block-heading\">Test Server Installation<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The server could take a few minutes to deploy and fully initialize; so be patient.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Check the Docker logs using the command:<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker logs -f cb-server\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the setup is completed, you should see output similar to that shown in below:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/log-output.png\" alt=\"Server set up output\" title=\"#width=300px\"><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Now check the required data is in place:\na. Open up <a href=\"http:\/\/localhost:8091\">http:\/\/localhost:8091<\/a> in a browser.\nb. Sign in as <strong>Administrator<\/strong> and <strong>password<\/strong> in login page.\nc. Go to <strong>buckets<\/strong> menu and confirm <strong>userprofile<\/strong> bucket is created<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/confirm-bucket-created.png\" alt=\"userprofile bucket\" title=\"#width=300px\"><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>security<\/strong> menu and confirm <strong>admin<\/strong> user is created.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/confirm-admin-user-created.png\" alt=\"userprofile bucket\" title=\"#width=300px\"><\/p>\n\n\n\n<h4 id=\"h-sync-gateway\" class=\"wp-block-heading\">Sync Gateway<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will install, configure, and run Sync Gateway.<\/p>\n\n\n\n<h5 id=\"h-configuration\" class=\"wp-block-heading\">Configuration<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">When using Sync Gateway, we can opt to provide a bootstrap configuration &#8212; see: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/configuration-overview.html\">Sync Gateway Configuration<\/a>.  We would then provision database, sync and other configuration using the Admin REST endpoints Alternatively, we can continue to run in legacy-mode, using the Pre-3.0 configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial &#8211; for the purposes of backward compatibility &#8211; we will run 3.x using its\n<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/configuration-properties-legacy.html\">legacy configuration option<\/a>.  That is, we will be running with the <em><code>disable_persistent_config<\/code><\/em> option in the configuration file set to <em><code>true<\/code><\/em>.  You can, if you wish, run a 2.8 version of Sync Gateway instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration files corresponding to this sample application are shown in Table 1.\nThey are available in the github repo hosting the app, which you cloned &#8211; look in:\n<code>\/path\/to\/cloned\/repo\/android-java-cblite-userprofile-sync\/src\/<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Table 1. Available configuration files<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table>\n<thead>\n<tr>\n<th>Release<\/th>\n<th>Filename<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>3.x<\/td>\n<td><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-sync\/blob\/main\/src\/sync-gateway-config-userprofile-demo-3-x-legacy.json\">sync-gateway-config-userprofile-demo-3-x-legacy.json<\/a><\/td>\n<\/tr>\n<tr>\n<td>2.x<\/td>\n<td><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-sync\/blob\/main\/src\/sync-gateway-config-userprofile-demo-2-x.json\">sync-gateway-config-userprofile-demo-2-x.json<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n\n\n<h4 id=\"h-deploy\" class=\"wp-block-heading\">Deploy<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Let us configure and launch Sync Gateway in a Docker container.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Switch to the the folder containing the cloned configuration files, using:<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>cd \/path\/to\/cloned\/repo\/android-java-cblite-userprofile-sync\/src\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Make sure no Sync Gateway container exists, using:<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker stop sync-gateway &amp;&amp; docker rm sync-gateway\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Listing the json files in the directory you should see configuration files for the latest major version and the previous major version in this folder.  Choose an appropriate version.<\/li>\n\n<\/ol>\n\n\n\n<h5 id=\"h-strongfor-nonwindows-systemsstrong\" class=\"wp-block-heading\"><strong>For non-Windows Systems<\/strong><\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Launch Sync Gateway in a Docker container using directions below based on the version you are using.<\/p>\n\n\n\n<h5 id=\"h-sync-gateway-3-x\" class=\"wp-block-heading\">Sync Gateway 3.x<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Configuring and running Sync Gateway 3.x in Docker using the configuration in <code>sync-gateway-config-userprofile-demo-3-x-legacy.json<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note the use of <code>disable_persistent_config<\/code> in the configuration file to force legacy configuration mode.<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker run -p 4984-4986:4984-4986 \n--network workshop \n--name sync-gateway \n-d \n-v `pwd`\/sync-gateway-config-userprofile-demo-3-x-legacy.json \n\/etc\/sync_gateway\/sync_gateway.json \ncouchbase\/sync-gateway:3.0.0-enterprise \n\/etc\/sync_gateway\/sync_gateway.json\n<\/code><\/pre>\n\n\n\n<h5 id=\"h-sync-gateway-2-x\" class=\"wp-block-heading\">Sync Gateway 2.x<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Configuring and running Sync Gateway 2.8.<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker run -p 4984-4986:4984-4986 \n--network workshop \n--name sync-gateway \n-d \n-v `pwd`\/sync-gateway-config-userprofile-demo-2-x.json:\n\/etc\/sync_gateway\/sync_gateway.json \ncouchbase\/sync-gateway:2.8.4-enterprise \n\/etc\/sync_gateway\/sync_gateway.json\n<\/code><\/pre>\n\n\n\n<h5 id=\"h-strongfor-windows-systemsstrong\" class=\"wp-block-heading\"><strong>For Windows Systems<\/strong><\/h5>\n\n\n\n<h5 id=\"h-sync-gateway-3-x\" class=\"wp-block-heading\">Sync Gateway 3.x<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Configure and run Sync Gateway 3.0 in legacy mode.<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker run -p 4984-4986:4984-4986 ^\n--network workshop ^\n--name sync-gateway ^\n-d -v %cd%sync-gateway-config-userprofile-demo-3-x-legacy.json:^\n\/etc\/sync_gateway\/sync_gateway.json ^\ncouchbase\/sync-gateway:3.0.0-enterprise ^\n\/etc\/sync_gateway\/sync_gateway.json\n<\/code><\/pre>\n\n\n\n<h5 id=\"h-sync-gateway-2-x\" class=\"wp-block-heading\">Sync Gateway 2.x<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Configuring and running Sync Gateway 2.8.<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker run -p 4984-4986:4984-4986 ^\n--network workshop ^\n--name sync-gateway ^\n-d ^\n-v %cd%\/sync-gateway-config-userprofile-demo-2-x.json:^\netc\/sync_gateway\/sync_gateway.json ^\ncouchbase\/sync-gateway:2.8.4-enterprise ^\n\/etc\/sync_gateway\/sync_gateway.json\n<\/code><\/pre>\n\n\n\n<h5 id=\"h-test-the-installation\" class=\"wp-block-heading\">Test the Installation<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Now we can confirm that the Sync Gateway is up and running.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Check the log messages.<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>docker logs -f sync-gateway\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You will see a series of log messages.  Make sure there are no errors.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open up <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"http:\/\/localhost:4984\">http:\/\/localhost:4984<\/a> in your browser.  You should see equivalent of the following message:<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>{&quot;couchdb&quot;:&quot;Welcome&quot;,&quot;vendor&quot;: { &quot;name&quot;:&quot;Couchbase Sync Gateway&quot;, &quot;version&quot;:&quot;3.0&quot; },\n&quot;version&quot;:&quot;Couchbase Sync Gateway\/3.0.0(460;26daced) EE&quot;}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have the server and the sync gateway installed, we can verify data sync between Couchbase Lite enabled apps.<\/p>\n\n\n\n<h3 id=\"h-sync-function\" class=\"wp-block-heading\">Sync Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A key component of the sync process is the Sync Function and we will first look at how that can be set-up to control how data sync works.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Sync Function is a Javascript function that is specified as part of the <a href=\"#configuration\">Sync Gateway Configuration<\/a>. It handles <a href=\"#authorization\">Authorization<\/a>, <a href=\"#data-validation\">Data Validation<\/a>, <a href=\"#data-routing\">Data Routing<\/a>, and <a href=\"#access-control\">Access Countrol<\/a>.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\n<p>Open the your configuration file using a text editor of your choice.  It will be located in the repo at <code>\/path\/to\/cloned\/repo\/android-java-cblite-userprofile-sync\/src<\/code>.<\/p>\n<\/li>\n\n\n<li>\n<p>Locate the <code>sync<\/code> setting in the file.<\/p>\n<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can follow along with the rest of the sections below.<\/p>\n\n\n\n<h4 id=\"h-authorization\" class=\"wp-block-heading\">Authorization<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">We use <em>Basic Authentication<\/em> in our application.  The Id of the user making the request is specified in the <code>Authorization<\/code> header.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Locate the <em><code>\/*Authorization*\/<\/code><\/em> section of the Sync Function.  You will see we are using the Sync functions <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/guides\/sync-gateway\/sync-function-api-guide\/index.html#requireuserusername\"><code>requireUser()<\/code><\/a> API to verify that the <code>email<\/code> property specified in the Document matches the Id of the user making the request.<\/p>\n\n\n\n<pre class=\"wp-block-code language-js\"><code>function sync(doc, oldDoc) {\n   ....\n   \/* Authorization *\/\n\n  \/\/ Verify the user making the request is the same as the one in doc&#039;s email\n  requireUser(doc.email);\n  .....\n}\n<\/code><\/pre>\n\n\n\n<h4 id=\"h-data-validation\" class=\"wp-block-heading\">Data Validation<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">In this case, we are doing some basic validation of the contents of the Document:<\/p>\n\n\n\n<pre class=\"wp-block-code language-js\"><code>\/* Data Validation *\/\n\n\/\/ Validate the presence of email field.\n\/\/ This is the &quot;username&quot; \nvalidateNotEmpty(&quot;email&quot;, doc.email);\n\n\/\/ Validate that the document Id _id is prefixed by owner \nvar expectedDocId = &quot;user&quot; + &quot;::&quot; + doc.email;\n\n\nif (expectedDocId != doc._id) {\n  \/\/ reject document\n  throw({forbidden: &quot;user doc Id must be of form user::email&quot;});\n}\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Verify that the <code>email<\/code> property is not null. If it&#8217;s null, we throw a JS exception (see <code>validateNotEmpty()<\/code> function)<\/li>\n\n\n<li>If this a new document, then verify that the <code>Id<\/code> of the Document is of the required format (i.e. <strong><em>&#8220;user::&lt;email&gt;&#8221;<\/em><\/strong>). We throw an exception if that&#8217;s not the case.<\/li>\n\n\n<li>If this is a document update, then verify that the <code>email<\/code> property value has not changed. Again, we throw an exception if that&#8217;s not the case.<\/li>\n\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>NOTE<\/strong>:  You can learn more about the Sync Function in the documentation here: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/sync-function.html\">Sync Function API<\/a>.<\/p>\n<\/blockquote>\n\n\n\n<h4 id=\"h-data-routing\" class=\"wp-block-heading\">Data Routing<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/channels.html\"><code>channels<\/code><\/a> are a mechanism to &#8220;tag&#8221; documents.  They are typically used to route\/seggregate documents based on the contents of those document.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Combined with <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/sync-function-api-access-cmd.html\">access()<\/a> and <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/sync-function-api-require-access-cmd.html\"><code>requireAccess() <\/code><\/a> API, the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/channels.html\">channel()<\/a> API can be used to enforce <a href=\"#access-control\">Access Control<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As we shall see in a later section, clients can use channels to pull only a subset of documents.<\/p>\n\n\n\n<pre class=\"wp-block-code language-js\"><code>  \/* Routing *\/\n  \/\/ Add doc to the user&#039;s channel.\n  var email = getEmail();\n\n  var channelId = &quot;channel.&quot;+ username; \n  channel(channelId); \n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Retrieve the the email property specified in the document. We will uses this as our user and channel name.<\/li>\n\n\n<li>Next, we generate the channel name from the email property.<\/li>\n\n\n<li>Finally we route the document to the channel. The channel comes into existence the first time a document is added to it.<\/li>\n\n<\/ol>\n\n\n\n<h4 id=\"h-access-control\" class=\"wp-block-heading\">Access Control<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">We can enforce access control to channels using the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/sync-function-api-access-cmd.html\">access () API<\/a>. This approach ensures that only users with access to a specific channel will be able to retrieve documents in the channel.<\/p>\n\n\n\n<pre class=\"wp-block-code language-js\"><code> \/\/ Give user read access to channel\n access(username, channelId);\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-starting-replication\" class=\"wp-block-heading\">Starting Replication<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Two-way Replication between the app and the Sync Gateway is enabled when the user logs into the app.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-standalone\/blob\/main\/src\/app\/src\/main\/java\/com\/couchbase\/userprofile\/util\/DatabaseManager.java\"><strong>DatabaseManager.java<\/strong><\/a> file and locate the <code>startPushAndPullReplicationForCurrentUser()<\/code> function.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>public static void startPushAndPullReplicationForCurrentUser(String username, String password)\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Next, we create an instance of the <code>ReplicatorConfiguration<\/code> instance that specifies the source and target database and you can optionally, override the default configuration settings.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>ReplicatorConfiguration config = new ReplicatorConfiguration(userprofileDatabase, new URLEndpoint(url)); \/\/ &lt;1&gt;\nconfig.setReplicatorType(ReplicatorConfiguration.ReplicatorType.PUSH_AND_PULL); \/\/ &lt;2&gt;\nconfig.setContinuous(true); \/\/ &lt;3&gt;\nconfig.setAuthenticator(new BasicAuthenticator(username, password)); \/\/ &lt;4&gt;\nconfig.setChannels(Arrays.asList(&quot;channel.&quot; + username)); \/\/ &lt;5&gt;\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Initialize with <code>source<\/code> as the local Couchbase Lite database and the <code>remote<\/code> target as the Sync Gateway<\/li>\n\n\n<li>Replication <code>type<\/code> of <code>PUSH_AND_PULL<\/code> indicates that we require two-way sync. A value of <code>.PUSH<\/code> specifies that we only pull data from the Sync Gateway. A value of <code>.PULL<\/code> specifies that we only push data.<\/li>\n\n\n<li>The <code>continuous<\/code> mode is specified to be <em>true<\/em> which means that changes are synced in real-time. A value of <em>false<\/em>  implies that data is only pulled from the Sync Gateway.<\/li>\n\n\n<li>This is where you specify the authentication credentials of the user. In the <a href=\"#authorization\">Authorization<\/a> section, we discussed that the Sync Gateway can enforce authorization checks using the <code>requireUser<\/code> API.<\/li>\n\n\n<li>The <code>channels<\/code> are used to specify the channels to pull from. Only documents belonging to the specified channels are synced. This is subject to <a href=\"#access-control\">Access Control<\/a> rights enforced at the Sync Gateway. This means that if a client does not have access to documents in a channel, the documents will not be synched even if the client specifies it in the replicator configuration.<\/li>\n\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initialize the <code>Replicator<\/code> with the <code>ReplicatorConfiguration<\/code><\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>replicator = new Replicator(config)\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In order to follow the replicator&#8217;s progress, we can attach a callback listener to it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Attaching a callback listener to the <code>Replicator<\/code> means we will be asynchronously notified of state changes.  This could be useful for instance, to inform the user of the progress of the replication.  It is an optional step shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>replicatorListenerToken = replicator.addChangeListener(new ReplicatorChangeListener() {\n  @Override\n  public void changed(ReplicatorChange change) {\n    if (change.getReplicator().getStatus().getActivityLevel().equals(Replicator.ActivityLevel.IDLE)) {\n      Log.e(&quot;Replication Comp Log&quot;, &quot;Scheduler Completed&quot;);\n    }\n    if (change.getReplicator().getStatus().getActivityLevel().equals(Replicator.ActivityLevel.STOPPED)\n            || change.getReplicator().getStatus().getActivityLevel().equals(Replicator.ActivityLevel.OFFLINE)) {\n      Log.e(&quot;Rep Scheduler  Log&quot;, &quot;ReplicationTag Stopped&quot;);\n    }\n  }\n});\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, with all that done, we can start the replicator.\u2009<\/p>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>replicator.start()\n<\/code><\/pre>\n\n\n\n<h3 id=\"h-stopping-replication\" class=\"wp-block-heading\">Stopping Replication<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When the user logs out of the app, the replication is stopped before the database is closed.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-standalone\/blob\/main\/src\/app\/src\/main\/java\/com\/couchbase\/userprofile\/util\/DatabaseManager.java\"><strong>DatabaseManager.java<\/strong><\/a> file and locate the <code>stopAllReplicationForCurrentUser()<\/code> function.<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>public static void stopAllReplicationForCurrentUser()\n\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Stop the replicator and remove any associated change listeners<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>replicator.removeChangeListener(replicatorListenerToken)\nreplicator.stop();\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>TIP<\/strong>: When you close a database, any active replicators, listeners and-or live queries are also be closed.<\/p>\n<\/blockquote>\n\n\n\n<h3 id=\"h-query-events-live-queries\" class=\"wp-block-heading\">Query Events \/ Live Queries<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Couchbase Lite applications can set up <strong>live queries<\/strong> in order to be asynchronously notified of changes to the database that affect the results of the query.  This can be very useful, for instance, in keeping a UI View up-to-date with the results of a query.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In our app, the user profile view is kept up-to-date using a live query that fetches the user profile data used to populate the view.  This means that, if the replicator pulls down changes to the user profile, they are automatically reflected in the view.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/couchbase-examples\/android-java-cblite-userprofile-sync\/blob\/main\/src\/app\/src\/main\/java\/com\/couchbase\/userprofile\/profile\/UserProfilePresenter.java\"> <strong>UserProfilePresenter.java<\/strong><\/a> file and locate the <code>fetchProfile()<\/code> function.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>public void fetchProfile()\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Build the Query using <code>QueryBuilder<\/code> API. If you are unfamiliar with this API, please see: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/developer.couchbase.com\/tutorial-quickstart-android-java-query\">Quickstart in Couchbase Lite Query with Android and Java<\/a> tutorial.<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>Query query = QueryBuilder\n  .select(SelectResult.all())\n  .from(DataSource.database(database))\n  .where(Meta.id.equalTo(Expression.string(docId))); \n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note<\/strong>:  We query for documents based on document Id. In our app, there should be exactly one user profile document corresponding to this Id.<\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Attach listener callback to the query to make it live<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code language-java\"><code>query.addChangeListener(new QueryChangeListener() {\n\n  @Override\n  public void changed(QueryChange change) { \/\/ &lt;1&gt;\n    ResultSet rows = change.getResults();\n    Result row = null;\n    Map&lt;String, Object&gt; profile = new HashMap&lt;&gt;(); \/\/ &lt;2&gt;\n    profile.put(&quot;email&quot;, DatabaseManager.getSharedInstance().currentUser);\n    while ((row = rows.next()) != null) {\n      Dictionary dictionary = row.getDictionary(&quot;userprofile&quot;); \/\/ &lt;3&gt;\n\n      if (dictionary != null) {\n        profile.put(&quot;name&quot;, dictionary.getString(&quot;name&quot;)); \/\/ &lt;4&gt;\n        profile.put(&quot;address&quot;, dictionary.getString(&quot;address&quot;)); \/\/ &lt;4&gt;\n        profile.put(&quot;imageData&quot;, dictionary.getBlob(&quot;imageData&quot;)); \/\/ &lt;4&gt;\n        profile.put(&quot;university&quot;, dictionary.getString(&quot;university&quot;)); \/\/ &lt;4&gt;\n        profile.put(&quot;type&quot;, dictionary.getString(&quot;type&quot;)); \/\/ &lt;4&gt;\n      }\n    }\n    mUserProfileView.showProfile(profile);\n}\n});\n<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Attach a listener callback to the query. Attaching a listener automatically makes it <em>live<\/em> so any time there is a change in the user profile data in the underlying database, the callback would be invoked<\/li>\n\n\n<li>Create an instance of UserRecord. This will be populated with the query results.<\/li>\n\n\n<li>The <code>SelectResult.all()<\/code> method is used to query all the properties of a document. In this case, the document in the result is embedded in a dictionary where the key is the database name, which is <strong><em>&#8220;userprofile&#8221;<\/em><\/strong>. So we retrieve the <a href=\"https:\/\/docs.couchbase.com\/mobile\/2.0\/couchbase-lite-java\/db021\/index.html?com\/couchbase\/lite\/Dictionary.html\"><code>Dictionary<\/code><\/a> at key <strong><em>&#8220;userprofile&#8221;<\/em><\/strong>.<\/li>\n\n\n<li>We use appropriate <em>type getters<\/em> to retrieve values and populate the <strong><em>UserRecord<\/em><\/strong> instance<\/li>\n\n<\/ol>\n\n\n\n<h3 id=\"h-exercises\" class=\"wp-block-heading\">Exercises<\/h3>\n\n\n\n<h4 id=\"h-exercise-1\" class=\"wp-block-heading\">Exercise 1<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">In this exercise, we will observe how changes made on one app are synced across to the other app<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The app should be running in two simulators side by side<\/li>\n\n\n<li>Log into both the simulators with the same userId and password. Use the values <strong><em>&#8220;<a href=\"mailto:demo@example.com\">demo@example.com<\/a>&#8220;<\/em><\/strong> and <strong><em>&#8220;password&#8221;<\/em><\/strong> for user Id and password fields respectively<\/li>\n\n\n<li>On one simulator, enter values in the user and address fields.<\/li>\n\n\n<li>Confirm that changes show up in the app on the other simulator.<\/li>\n\n\n<li>Similarly, make changes to the app in the other simulator and confirm that the changes are synced over to the first simulator.<\/li>\n\n<\/ol>\n\n\n\n<h4 id=\"h-exercise-2\" class=\"wp-block-heading\">Exercise 2<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">In this exercise, we will observe changes made via Sync Gateway are synced over to the apps<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\n<p>Make sure you have completed Exercise 1. This is to ensure that you have the appropriate user profile document (with document Id of &#8220;user::<a href=\"mailto:demo@example.com\">demo@example.com<\/a>&#8220;) created through the app and synced over to the Sync Gateway.<\/p>\n<\/li>\n\n\n<li>\n<p>Open the command terminal and issue the following command to get the user profile document via GET Document REST API. We will be using <code>curl<\/code> to issue the request. If you haven&#8217;t done so, please install curl as indicated in the Prerequisites section.<\/p>\n<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>curl -X GET http:\/\/localhost:4984\/userprofile\/user::demo@example.com --user demo@example.com\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>NOTE<\/strong>:  This GET retrieves the userprofile document with the id <strong>user::<a href=\"mailto:demo@example.com\">demo@example.com<\/a><\/strong><\/p>\n<\/blockquote>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Your response should look something like the response below. The exact contents depend on the user profile information that you provided via your mobile app.<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>{\n    &quot;_attachments&quot;: { &lt;2&gt;\n        &quot;blob_1&quot;: {\n            &quot;content_type&quot;: &quot;image\/jpeg&quot;,\n            &quot;digest&quot;: &quot;sha1-S8asPSgzA+F+fp8\/2DdIy4K+0U8=&quot;,\n            &quot;length&quot;: 14989,\n            &quot;revpos&quot;: 2,\n            &quot;stub&quot;: true\n        }\n    },\n    &quot;_id&quot;: &quot;user::demo@example.com&quot;,\n    &quot;_rev&quot;: &quot;2-3a76cfa911e2c54d1e82b29dbffc7f4e5a9bc265&quot;, \/\/&lt;1&gt;\n    &quot;address&quot;: &quot;&quot;,\n    &quot;email&quot;: &quot;demo@example.com&quot;,\n    &quot;image&quot;: {\n        &quot;@type&quot;: &quot;blob&quot;,\n        &quot;content_type&quot;: &quot;image\/jpeg&quot;,\n        &quot;digest&quot;: &quot;sha1-S8asPSgzA+F+fp8\/2DdIy4K+0U8=&quot;,\n        &quot;length&quot;: 14989\n    },\n    &quot;name&quot;: &quot;&quot;,\n    &quot;type&quot;: &quot;user&quot;,\n    &quot;university&quot;: &quot;Missouri State University&quot;\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p>If you had updated an image via the mobile app, you should see an <strong>&#8220;_attachments&#8221;<\/strong> property. This entry holds an array of attachments corresponding to each image blob entry added by the mobile app. This property is added by the Sync Gateway when it processes the document. You can learn more about how image Blob types are mapped to attachments <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/couchbase-lite\/3.0\/swift\/blob.html\">here<\/a>.<\/p>\n<\/li>\n\n\n<li>\n<p>Record the revision Id of the document.  You will need this when you update the document<\/p>\n<\/li>\n\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the command terminal, issue the following command to update the user profile document via <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/rest-api.html#\/document\/AddOrUpdateDocument\">PUT Document REST API<\/a>.<\/li>\n\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>NOTE<\/strong>: We chose to show how to update the address field via the REST API.  You can choose to update any other profile information if you like.  You will be prompted to enter the users password when you submit the curl command.<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>curl -X PUT \n  &#039;http:\/\/localhost:4985\/userprofile\/user::demo@example.com?rev=3-12d203d6024c8b844c5ed736c726ac63379e05dc&#039; \n  -H &#039;Accept: application\/json&#039; \n  -H &#039;Cache-Control: no-cache&#039; \n  -H &#039;Content-Type: application\/json&#039; \n  -d &#039;{\n    &quot;address&quot;: &quot;101 Main Street&quot;, \/\/&lt;1&gt;\n    &quot;email&quot;: &quot;demo@example.com&quot;,\n    &quot;image&quot;: {\n        &quot;@type&quot;: &quot;blob&quot;,\n        &quot;content_type&quot;: &quot;image\/jpeg&quot;,\n        &quot;digest&quot;: &quot;sha1-S8asPSgzA+F+fp8\/2DdIy4K+0U8=&quot;,\n        &quot;length&quot;: 14989\n    },\n    &quot;name&quot;: &quot;&quot;,\n    &quot;type&quot;: &quot;user&quot;,\n    &quot;university&quot;: &quot;Missouri State University&quot;\n}&#039;\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Here, in the <code>PUT<\/code>, we specify the:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>user id (<code>user::demo@example.com<\/code>)<\/li>\n\n\n<li>revision Id (from the previous step <code>3-033fcbaf269d65a9247067be76d664f1111d033b<\/code>) to select the item we want to update<\/li>\n\n<\/ul>\n<\/blockquote>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\n<p>Confirm that you get a HTTP <strong><em>&#8220;201 Created&#8221;<\/em><\/strong> status code<\/p>\n<\/li>\n\n\n<li>\n<p>As soon as you update the document via the Sync Gateway REST API, confirm that the changes show up in the mobile app on the simulator.<\/p>\n<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\".\/sync_from_sgw.gif\" alt=\"App Sync\"><\/p>\n\n\n\n<h3 id=\"h-handling-conflicts-during-data-synchronization\" class=\"wp-block-heading\">Handling Conflicts during Data Synchronization<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Data conflicts are inevitable in an environment where you can potentially have multiple writes updating the same data concurrently. Couchbase Mobile supports <strong><em>Automated Conflict Resolution<\/em><\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can learn more about automated conflict resolution in this blog <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/blog.couchbase.com\/document-conflicts-couchbase-mobile\/\">Document Conflicts &amp; Resolution<\/a>.<\/p>\n\n\n\n<h3 id=\"h-learn-more\" class=\"wp-block-heading\">Learn More<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations on completing this tutorial!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial walked you through an example of how to use a Sync Gateway to synchronize data between Couchbase Lite enabled clients. We discussed how to configure your Sync Gateway to enforce relevant access control, authorization and data routing between Couchbase Lite enabled clients.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check out the following links for further details<\/p>\n\n\n\n<h4 id=\"h-further-reading\" class=\"wp-block-heading\">Further Reading<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/docs.couchbase.com\/sync-gateway\/3.0\/configuration-overview.html\">Sync Gateway Configuration<\/a><\/p>\n<\/li>\n\n\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/blog.couchbase.com\/category\/couchbase-mobile\/?ref=blog-menu\">Couchbase Mobile Blog<\/a><\/p>\n<\/li>\n\n\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/blog.couchbase.com\/?s=sync+function\">Sync function blogs<\/a><\/p>\n<\/li>\n\n\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/blog.couchbase.com\/data-replication-couchbase-mobile\/\">Overview of Replication Protocol<\/a><\/p>\n<\/li>\n\n\n<li>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/blog.couchbase.com\/document-conflicts-couchbase-mobile\/\">Document Conflicts &amp; Resolution<\/a><\/p>\n<\/li>\n\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an Internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile uses a websocket based replication protocol. The core functions of the Sync Gateway include: This tutorial will demonstrate how to [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"menu_order":0,"template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"_acf":"","footnotes":""},"tutorial-languages":[595],"tutorial-tags":[587],"tutorial-technologies":[548,585,549,597],"tutorial-types":[550],"class_list":["post-10281","tutorials","type-tutorials","status-publish","hentry","tutorial-languages-android-java","tutorial-tags-android","tutorial-technologies-kv","tutorial-technologies-mobile","tutorial-technologies-query","tutorial-technologies-sync-gateway","tutorial-types-quickstart"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.8 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Quickstart in Couchbase Lite Data Sync with Android and Java - Couchbase<\/title>\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\/de\/developers\/tutorials\/quickstart-android-java-sync\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Quickstart in Couchbase Lite Data Sync with Android and Java\" \/>\n<meta property=\"og:description\" content=\"Introduction Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an Internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile uses a websocket based replication protocol. The core functions of the Sync Gateway include: This tutorial will demonstrate how to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/\" \/>\n<meta property=\"og:site_name\" content=\"Couchbase\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Couchbase\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2548\" \/>\n\t<meta property=\"og:image:height\" content=\"1171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@couchbase\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"21\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-android-java-sync\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-android-java-sync\\\/\",\"name\":\"Quickstart in Couchbase Lite Data Sync with Android and Java - Couchbase\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#website\"},\"datePublished\":\"2023-06-23T08:43:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-android-java-sync\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-android-java-sync\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/developers\\\/tutorials\\\/quickstart-android-java-sync\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Quickstart in Couchbase Lite Data Sync with Android and Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/\",\"name\":\"Couchbase\",\"description\":\"The Operational Data Platform for AI\u2122\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#organization\"},\"alternateName\":\"Couchbase, Inc.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#organization\",\"name\":\"Couchbase\",\"alternateName\":\"Couchbase, Inc.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Couchbase_Logo_Couchbase_Token_Red-1.png\",\"width\":1129,\"height\":1129,\"caption\":\"Couchbase\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Couchbase\\\/\",\"https:\\\/\\\/x.com\\\/couchbase\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/CouchbaseServer\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/couchbase\\\/\",\"https:\\\/\\\/github.com\\\/couchbase\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Couchbase,_Inc.\"],\"description\":\"Couchbase is a database software company headquartered in San Jose, California, providing an operational data platform for AI used by hundreds of global enterprises.\",\"legalName\":\"Couchbase, Inc.\",\"foundingDate\":\"2011-01-01\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Quickstart in Couchbase Lite Data Sync with Android and Java - Couchbase","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\/de\/developers\/tutorials\/quickstart-android-java-sync\/","og_locale":"de_DE","og_type":"article","og_title":"Quickstart in Couchbase Lite Data Sync with Android and Java","og_description":"Introduction Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an Internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile uses a websocket based replication protocol. The core functions of the Sync Gateway include: This tutorial will demonstrate how to [&hellip;]","og_url":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/","og_site_name":"Couchbase","article_publisher":"https:\/\/www.facebook.com\/Couchbase\/","og_image":[{"width":2548,"height":1171,"url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/10\/Cloud-2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@couchbase","twitter_misc":{"Est. reading time":"21\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/","url":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/","name":"Quickstart in Couchbase Lite Data Sync with Android and Java - Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/de\/#website"},"datePublished":"2023-06-23T08:43:43+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/de\/developers\/tutorials\/quickstart-android-java-sync\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/"},{"@type":"ListItem","position":2,"name":"Quickstart in Couchbase Lite Data Sync with Android and Java"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/de\/#website","url":"https:\/\/www.couchbase.com\/de\/","name":"Couchbase","description":"The Operational Data Platform for AI\u2122","publisher":{"@id":"https:\/\/www.couchbase.com\/de\/#organization"},"alternateName":"Couchbase, Inc.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/de\/#organization","name":"Couchbase","alternateName":"Couchbase, Inc.","url":"https:\/\/www.couchbase.com\/de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.couchbase.com\/de\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","contentUrl":"https:\/\/www.couchbase.com\/wp-content\/uploads\/2026\/11\/Couchbase_Logo_Couchbase_Token_Red-1.png","width":1129,"height":1129,"caption":"Couchbase"},"image":{"@id":"https:\/\/www.couchbase.com\/de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Couchbase\/","https:\/\/x.com\/couchbase","https:\/\/www.youtube.com\/c\/CouchbaseServer","https:\/\/www.linkedin.com\/company\/couchbase\/","https:\/\/github.com\/couchbase\/","https:\/\/en.wikipedia.org\/wiki\/Couchbase,_Inc."],"description":"Couchbase ist ein in San Jose, Kalifornien, ans\u00e4ssiges Unternehmen f\u00fcr Datenbanksoftware, das eine operative Datenplattform f\u00fcr KI bereitstellt, die von Hunderten von globalen Unternehmen eingesetzt wird.","legalName":"Couchbase, Inc.","foundingDate":"2011-01-01"}]}},"acf":[],"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorials\/10281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorials"}],"about":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/types\/tutorials"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorials\/10281\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/media?parent=10281"}],"wp:term":[{"taxonomy":"tutorial-languages","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-languages?post=10281"},{"taxonomy":"tutorial-tags","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-tags?post=10281"},{"taxonomy":"tutorial-technologies","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-technologies?post=10281"},{"taxonomy":"tutorial-types","embeddable":true,"href":"https:\/\/www.couchbase.com\/de\/wp-json\/wp\/v2\/tutorial-types?post=10281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}