{"id":479,"date":"2015-12-16T01:03:52","date_gmt":"2015-12-16T01:03:51","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/"},"modified":"2015-12-16T01:03:52","modified_gmt":"2015-12-16T01:03:51","slug":"using-couchbase-in-your-ionic-framework-application-part-2","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/using-couchbase-in-your-ionic-framework-application-part-2\/","title":{"rendered":"Using Couchbase in Your Ionic Framework Application Part 2"},"content":{"rendered":"\n<p>Previously in <a href=\"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-1\/\">part one of this series<\/a><br>\nregarding Ionic Framework and Couchbase, I wrote about using Couchbase Lite to do local CRUD<br>\n(Create, Retrieve, Update, Delete) operations in a todo list example. This time around we&#8217;re going to take it to the next level and see<br>\nhow to replicate changes across multiple devices and platforms using the Couchbase Sync Gateway.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Prerequisites<\/h2>\n\n\n\n<p>In order to be successful in this tutorial, you need to have done the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Completed part one of the Ionic Framework blog series<\/li>\n\n\n<li>Downloaded the Couchbase Sync Gateway<\/li>\n\n\n<li>The Android SDK if building for Android<\/li>\n\n\n<li>A Mac with Xcode installed if building for iOS<\/li>\n\n<\/ul>\n\n\n\n<p>This tutorial is going to pick up exactly where part one of the series left off, so it is important that you had the first part in a working<br>\nstate before continuing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring Couchbase Sync Gateway<\/h2>\n\n\n\n<p>In order to use Sync Gateway with our application we first need to create a configuration file. Create a file called<br>\n<strong>sync-gateway-config.json<\/strong> at the root of your project and include the following:<\/p>\n\n\n<p>[crayon lang=&#8221;json&#8221;]<br \/>\n{<br \/>\n    &#8220;log&#8221;: [&#8220;CRUD&#8221;, &#8220;REST+&#8221;, &#8220;Access&#8221;],<br \/>\n    &#8220;databases&#8221;: {<br \/>\n        &#8220;todos&#8221;: {<br \/>\n            &#8220;server&#8221;: &#8220;walrus:&#8221;,<br \/>\n            &#8220;users&#8221;: {<br \/>\n                &#8220;GUEST&#8221;: {&#8220;disabled&#8221;: false, &#8220;admin_channels&#8221;: [&#8220;*&#8221;]}<br \/>\n            },<br \/>\n            &#8220;sync&#8221;: `<br \/>\n                function(doc, oldDoc) {<br \/>\n                    \/\/ NOTE this function is the same across the iOS, Android, and PhoneGap versions.<br \/>\n                    if (doc.type == &#8220;task&#8221;) {<br \/>\n                        if (!doc.list_id) {<br \/>\n                            throw({forbidden : &#8220;items must have a list_id&#8221;})<br \/>\n                        }<br \/>\n                        channel(&#8220;task-&#8220;+doc.list_id);<br \/>\n                    } else if (doc.type == &#8220;list&#8221;) {<br \/>\n                        channel(&#8220;list-&#8220;+doc._id);<br \/>\n                        if (!doc.owner) {<br \/>\n                            throw({forbidden : &#8220;list must have an owner&#8221;})<br \/>\n                        }<br \/>\n                        if (oldDoc) {<br \/>\n                            var oldOwnerName = oldDoc.owner.substring(oldDoc.owner.indexOf(&#8220;:&#8221;)+1);<br \/>\n                            requireUser(oldOwnerName)<br \/>\n                        }<br \/>\n                        var ownerName = doc.owner.substring(doc.owner.indexOf(&#8220;:&#8221;)+1);<br \/>\n                        access(ownerName, &#8220;list-&#8220;+doc._id);<br \/>\n                    }<br \/>\n                }<br \/>\n            `<br \/>\n        }<br \/>\n    }<br \/>\n}<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>Don&#8217;t let the above overwhelm you as there isn&#8217;t too much going on. Most of the logic just checks to make sure documents have all the<br>\nrequired properties.<\/p>\n\n\n\n<p>To highlight some of the main things happening here, first take a look at the <strong>databases.todos<\/strong> property.<br>\nThis is going to be our remote database. The server we&#8217;re using is <strong>walrus<\/strong> which is a memory based solution bundled<br>\ninto the Sync Gateway. It is good for testing before you&#8217;re ready to have it save into Couchbase Server. We are also choosing to enable<br>\nguest access, so registered users won&#8217;t be required for now.<\/p>\n\n\n\n<p>This brings us into the sync JavaScript code. If the document is of type task, we check to see if a parent list id exists, otherwise we<br>\nforce a fail. If it exists, then we save the document in the Sync Gateway prefixed with <strong>task-<\/strong> in the key. If the document<br>\ntype is not a task, then it might be a list. Check to make sure the document has an <strong>owner<\/strong> property and save it to the<br>\nSync Gateway prefixed with <strong>list-<\/strong> in the key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding a New Ionic Route For Login<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Adding to the AngularJS UI-Router<\/h3>\n\n\n\n<p>As of right now your AngularJS configuration should include two routes. One for the todo lists and one for tasks. What we want to do<br>\nnow is include a third route for signing into the Sync Gateway. Inside your project&#8217;s <strong>www\/js\/app.js<\/strong> file, make the following<br>\nchange:<\/p>\n\n\n<p>[crayon lang=&#8221;javascript&#8221;]<br \/>\ncouchbaseApp.config(function($stateProvider, $urlRouterProvider) {<br \/>\n    $stateProvider<br \/>\n        .state(&#8220;login&#8221;, {<br \/>\n            url: &#8220;\/login&#8221;,<br \/>\n            templateUrl: &#8220;templates\/login.html&#8221;,<br \/>\n            controller: &#8220;LoginController&#8221;<br \/>\n        })<br \/>\n        .state(&#8220;todoLists&#8221;, {<br \/>\n            url: &#8220;\/todoLists&#8221;,<br \/>\n            templateUrl: &#8220;templates\/todolists.html&#8221;,<br \/>\n            controller: &#8220;TodoListsController&#8221;<br \/>\n        })<br \/>\n        .state(&#8220;tasks&#8221;, {<br \/>\n            url: &#8220;\/tasks\/:listId&#8221;,<br \/>\n            templateUrl: &#8220;templates\/tasks.html&#8221;,<br \/>\n            controller: &#8220;TaskController&#8221;<br \/>\n        });<br \/>\n    $urlRouterProvider.otherwise(&#8220;\/login&#8221;);<br \/>\n});<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>Notice the new login state and that we changed our default route to be <strong>\/login<\/strong> instead of <strong>\/todoLists<\/strong>. The<br>\nroute is good to go, we just need to create the view and controller to finalize it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating a Login View<\/h3>\n\n\n\n<p>Inside your project&#8217;s <strong>www\/templates<\/strong> directory, create a file called <strong>login.html<\/strong> and add the following code:<\/p>\n\n\n\n<p><button class=\"button button-block button-balanced\">Guest Login<\/button><\/p>\n\n\n\n<p>Sign in as a guest user<\/p>\n\n\n\n<p>\u00a0<\/p>\n\n\n\n<p>It is just a simple view with a button on it. When the user clicks the button, the <strong>basicLogin()<\/strong> function is called which<br>\nwe&#8217;ll be creating in the login controller.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a Login Controller<\/h2>\n\n\n\n<p>The controller for handling sign-ins will accomplish one very major task. It will start the replication process between the Sync Gateway<br>\nand the local device. Here is slim version of our controller that should be added to the <strong>www\/js\/app.js<\/strong> file:<\/p>\n\n\n<p>[crayon lang=&#8221;javascript&#8221;]<br \/>\ncouchbaseApp.controller(&#8220;LoginController&#8221;, function($scope, $state, $ionicHistory) {<\/p>\n<p>    $ionicHistory.nextViewOptions({<br \/>\n        disableAnimate: true,<br \/>\n        disableBack: true<br \/>\n    });<\/p>\n<p>    $scope.basicLogin = function() { };<\/p>\n<p>});<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>Notice the <strong>$ionicHistory.nextViewOptions<\/strong> method. This is to prevent the hardware back button from taking users back<br>\nto the login screen after they&#8217;ve already logged in. More important for Android since iOS doesn&#8217;t have a hardware back.<\/p>\n\n\n\n<p>Next you&#8217;ll see the <strong>$scope.basicLogin()<\/strong> function that was called from the UI view. Its contents will look like the following:<\/p>\n\n\n<p>[crayon lang=&#8221;javascript&#8221;]<br \/>\n$scope.basicLogin = function() {<br \/>\n    todoDatabase.replicate(&#8220;todo&#8221;, &#8220;https:\/\/192.168.56.1:4984\/todos&#8221;, true).then(function(result) {<br \/>\n        todoDatabase.replicate(&#8220;https:\/\/192.168.56.1:4984\/todos&#8221;, &#8220;todo&#8221;, true).then(function(result) {<br \/>\n            $state.go(&#8220;todoLists&#8221;);<br \/>\n        }, function(error) {<br \/>\n            \/\/ There was an error replicating to the local device<br \/>\n        });<br \/>\n    }, function(error) {<br \/>\n        \/\/ There was an error replicating to the Sync Gateway<br \/>\n    });<br \/>\n};<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>The first thing that happens is replication from the local device to the sync gateway. It is set to continuously replicate all changes. If<br>\nreplication from local to remote starts successfully, the same happens for remote to local. Data will be continuously replicated from<br>\nthe remote Sync Gateway down to the device.<\/p>\n\n\n\n<p>If both are successful, the user will be redirected to the todo lists. Note that the Sync Gateway does not need to be operational to move<br>\npast login. If the server is not up, it will fail gracefully and still move on. Also note, that the IPs listed in the above function are<br>\nIPs that allowed me to communicate between simulator to the local host machine. They may differ for you and some research may need to be done.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding Owner Information To Document Data<\/h2>\n\n\n\n<p>Two minor changes need to be made to the way we store documents in the local database. In the <strong>$scope.insert<\/strong> of both<br>\ntask and todo list controllers, an <strong>owner<\/strong> property must be added. In this case the owner will be <strong>guest<\/strong>.<\/p>\n\n\n<p>[crayon lang=&#8221;javascript&#8221;]<br \/>\n$scope.insert = function() {<br \/>\n    $ionicPopup.prompt({<br \/>\n        title: &#8216;Enter a new TODO list&#8217;,<br \/>\n        inputType: &#8216;text&#8217;<br \/>\n    })<br \/>\n    .then(function(result) {<br \/>\n        var obj = {<br \/>\n            title: result,<br \/>\n            type: &#8220;list&#8221;,<br \/>\n            owner: &#8220;guest&#8221;<br \/>\n        };<br \/>\n        todoDatabase.createDocument(obj).then(function(result) {<br \/>\n            \/\/ Document created successfully<br \/>\n        }, function(error) {<br \/>\n            \/\/ Document creation failed<br \/>\n        });<br \/>\n    });<br \/>\n}<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>The above code is an example of one of the <strong>$scope.insert<\/strong> functions. Again the only difference here is that we added an<br>\n<strong>owner<\/strong> property.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing Your Project<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Running the Couchbase Sync Gateway<\/h3>\n\n\n\n<p>With the Sync Gateway downloaded, run the following from your Command Prompt or Terminal:<\/p>\n\n\n<p>[crayon lang=&#8221;bash&#8221;]<br \/>\n\/path\/to\/sync\/gateway\/bin\/sync_gateway \/path\/to\/project\/sync-gateway-config.json<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>The Sync Gateway should start without issues.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Testing for Android<\/h3>\n\n\n\n<p>With a device connected or a simulator running, from the Command Prompt or Terminal, run the following two commands to<br>\nbuild and install the APK file:<\/p>\n\n\n<p>[crayon lang=&#8221;bash&#8221;]<br \/>\nionic build android<br \/>\nadb install -r platforms\/android\/build\/outputs\/apk\/android-debug.apk<br \/>\n[\/crayon]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Testing for iOS<\/h3>\n\n\n\n<p>There are two good ways to do this. You can either build the project and open it with Xcode, or you can build and emulate the application<br>\nwithout launching Xcode. The first can be done like so:<\/p>\n\n\n<p>[crayon lang=&#8221;bash&#8221;]<br \/>\nionic build ios<br \/>\n[\/crayon]<\/p>\n\n\n\n<p>Then open the project&#8217;s <strong>platform\/ios\/<\/strong> directory and launch the Xcode project file.<\/p>\n\n\n\n<p>If you&#8217;ve installed the Node Package Manager (NPM) package <strong>ios-sim<\/strong>, you can do the following:<\/p>\n\n\n<p>[crayon lang=&#8221;bash&#8221;]<br \/>\nionic build ios<br \/>\nionic emulate ios<br \/>\n[\/crayon]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway, we&#8217;ve created a mobile todo list application that replicates data<br>\nlocally and remotely so it can be accessed across multiple devices and platforms. We used AngularJS to easily connect to the RESTful endpoints<br>\nthat Couchbase Lite exposes.<\/p>\n\n\n\n<p>This series can be downloaded in full from the <a href=\"https:\/\/github.com\/couchbaselabs\/todolite-ionic\">Couchbase Labs GitHub<\/a> page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Previously in part one of this series regarding Ionic Framework and Couchbase, I wrote about using Couchbase Lite to do local CRUD (Create, Retrieve, Update, Delete) operations in a todo list example. This time around we&#8217;re going to take it to the next level and see how to replicate changes across multiple devices and platforms [&hellip;]<\/p>\n","protected":false},"author":63,"featured_media":18,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[159,9],"tags":[160,161,162],"ppma_author":[148],"class_list":["post-479","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-couchbase-mobile","tag-apache-cordova","tag-ionic-framework","tag-ios"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Using Couchbase in Your Ionic Framework Application Part 2<\/title>\n<meta name=\"description\" content=\"This post focuses on how to replicate changes across multiple devices and platforms using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway.\" \/>\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\/pt\/using-couchbase-in-your-ionic-framework-application-part-2\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Couchbase in Your Ionic Framework Application Part 2\" \/>\n<meta property=\"og:description\" content=\"This post focuses on how to replicate changes across multiple devices and platforms using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/using-couchbase-in-your-ionic-framework-application-part-2\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/thepolyglotdeveloper\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-16T01:03:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase-nosql-dbaas.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nraboy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nic Raboy, Developer Advocate, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Using Couchbase in Your Ionic Framework Application Part 2\",\"datePublished\":\"2015-12-16T01:03:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/\"},\"wordCount\":1344,\"commentCount\":46,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/couchbase-nosql-dbaas.png\",\"keywords\":[\"apache cordova\",\"ionic framework\",\"ios\"],\"articleSection\":[\"Android\",\"Couchbase Mobile\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/\",\"name\":\"Using Couchbase in Your Ionic Framework Application Part 2\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2015-12-16T01:03:51+00:00\",\"description\":\"This post focuses on how to replicate changes across multiple devices and platforms using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-in-your-ionic-framework-application-part-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Couchbase in Your Ionic Framework Application 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\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/bb545ebe83bb2d12f91095811d0a72e1\",\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g8863514d8bed0cf6080f23db40e00354\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g\",\"caption\":\"Nic Raboy, Developer Advocate, Couchbase\"},\"description\":\"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.\",\"sameAs\":[\"https:\\\/\\\/www.thepolyglotdeveloper.com\",\"https:\\\/\\\/www.facebook.com\\\/thepolyglotdeveloper\",\"https:\\\/\\\/x.com\\\/nraboy\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/pt\\\/author\\\/nic-raboy-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Using Couchbase in Your Ionic Framework Application Part 2","description":"This post focuses on how to replicate changes across multiple devices and platforms using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway.","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\/pt\/using-couchbase-in-your-ionic-framework-application-part-2\/","og_locale":"pt_BR","og_type":"article","og_title":"Using Couchbase in Your Ionic Framework Application Part 2","og_description":"This post focuses on how to replicate changes across multiple devices and platforms using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway.","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/using-couchbase-in-your-ionic-framework-application-part-2\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2015-12-16T01:03:51+00:00","og_image":[{"width":1800,"height":630,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase-nosql-dbaas.png","type":"image\/png"}],"author":"Nic Raboy, Developer Advocate, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@nraboy","twitter_misc":{"Written by":"Nic Raboy, Developer Advocate, Couchbase","Est. reading time":"6 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Using Couchbase in Your Ionic Framework Application Part 2","datePublished":"2015-12-16T01:03:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/"},"wordCount":1344,"commentCount":46,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase-nosql-dbaas.png","keywords":["apache cordova","ionic framework","ios"],"articleSection":["Android","Couchbase Mobile"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/","url":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/","name":"Using Couchbase in Your Ionic Framework Application Part 2","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase-nosql-dbaas.png","datePublished":"2015-12-16T01:03:51+00:00","description":"This post focuses on how to replicate changes across multiple devices and platforms using the Couchbase PhoneGap plugin and the Couchbase Sync Gateway.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-in-your-ionic-framework-application-part-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using Couchbase in Your Ionic Framework Application 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":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","width":"1024","height":"1024","caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1","name":"Nic Raboy, Developer Advocate, Couchbase","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g8863514d8bed0cf6080f23db40e00354","url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","caption":"Nic Raboy, Developer Advocate, Couchbase"},"description":"Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.","sameAs":["https:\/\/www.thepolyglotdeveloper.com","https:\/\/www.facebook.com\/thepolyglotdeveloper","https:\/\/x.com\/nraboy"],"url":"https:\/\/www.couchbase.com\/blog\/pt\/author\/nic-raboy-2\/"}]}},"acf":[],"authors":[{"term_id":148,"user_id":63,"is_guest":0,"slug":"nic-raboy-2","display_name":"Nic Raboy, Developer Advocate, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=479"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/479\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/18"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=479"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}