{"id":2490,"date":"2017-01-11T15:00:00","date_gmt":"2017-01-11T15:00:00","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=2490"},"modified":"2025-06-13T20:15:27","modified_gmt":"2025-06-14T03:15:27","slug":"syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/","title":{"rendered":"Sincroniza\u00e7\u00e3o de documentos do Couchbase entre plataformas e dispositivos m\u00f3veis com NativeScript e Angular"},"content":{"rendered":"<p>Nos \u00faltimos dias, exploramos como criar um aplicativo simples para Android e iOS usando NativeScript, Angular e Couchbase. Primeiro, vimos como <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/key-value-operations-in-couchbase-mobile-via-nativescript-and-angular\/\">usar o Couchbase para opera\u00e7\u00f5es b\u00e1sicas de valor-chave<\/a> e ent\u00e3o vimos <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/querying-for-couchbase-documents-in-a-nativescript-angular-mobile-application\/\">como consultar o Couchbase como um banco de dados de documentos<\/a>. O cap\u00edtulo final \u00e9 adicionar suporte de replica\u00e7\u00e3o ao nosso aplicativo NativeScript usando o Couchbase Sync Gateway.<\/p>\n<p>Vamos expandir os dois exemplos anteriores para sincronizar dados entre plataformas e dispositivos usando o Couchbase Sync Gateway, NativeScript e Angular. Veja a seguinte imagem animada, por exemplo:<\/p>\n<div class=\"figure\"><img decoding=\"async\" src=\"\/wp-content\/original-assets\/2017\/january\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/ns-cb-profile-sync.gif\" alt=\"Couchbase Sync with NativeScript and Angular\" \/><\/div>\n<p>Quando um novo perfil \u00e9 adicionado ao dispositivo iOS, ele \u00e9 sincronizado com o dispositivo Android e, da mesma forma, na dire\u00e7\u00e3o oposta. Isso \u00e9 poss\u00edvel com muito pouco c\u00f3digo.<\/p>\n<h2 id=\"the-requirements\">Os requisitos<\/h2>\n<p>Os requisitos entre este exemplo e os dois anteriores mudaram um pouco. Para ter sucesso, voc\u00ea precisar\u00e1 do seguinte:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.nativescript.org\">NativeScript<\/a> 2.0+<\/li>\n<li>Gateway de sincroniza\u00e7\u00e3o do Couchbase<\/li>\n<\/ul>\n<p>O NativeScript, o Angular e o plug-in do Couchbase Lite podem ser obtidos por meio da CLI do NativeScript. N\u00e3o sincronizaremos nossos dados com o Couchbase Server neste exemplo, mas podemos fazer isso facilmente com poucas altera\u00e7\u00f5es.<\/p>\n<h2 id=\"picking-up-where-we-left-off\">Continuando de onde paramos<\/h2>\n<p>Para ter sucesso com este tutorial, voc\u00ea precisar\u00e1 ter visto <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/querying-for-couchbase-documents-in-a-nativescript-angular-mobile-application\/\">Parte 2<\/a> que tem sua pr\u00f3pria depend\u00eancia de ter visualizado <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/key-value-operations-in-couchbase-mobile-via-nativescript-and-angular\/\">Parte 1<\/a>. A maior parte do c\u00f3digo desses guias anteriores pode ser copiada e colada em um projeto.<\/p>\n<p>Antes de continuar, voc\u00ea dever\u00e1 ter um aplicativo NativeScript funcional de duas p\u00e1ginas com uma caixa de di\u00e1logo modal. Os dados desse aplicativo s\u00e3o salvos em <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/\">Couchbase<\/a> e consultados usando exibi\u00e7\u00f5es do MapReduce.<\/p>\n<h2 id=\"creating-an-angular-service-for-couchbase\">Cria\u00e7\u00e3o de um servi\u00e7o Angular para o Couchbase<\/h2>\n<p>Como a replica\u00e7\u00e3o de dados estar\u00e1 envolvida, precisamos nos certificar de que temos apenas uma \u00fanica inst\u00e2ncia do Couchbase em execu\u00e7\u00e3o no nosso aplicativo. No exemplo anterior, criamos uma nova inst\u00e2ncia por p\u00e1gina. N\u00e3o podemos fazer isso com a replica\u00e7\u00e3o porque podemos acabar replicando v\u00e1rias vezes, o que \u00e9 ineficiente.<\/p>\n<p>Para criar uma inst\u00e2ncia singleton do Couchbase, devemos criar um servi\u00e7o Angular. Crie um arquivo em seu projeto em <strong>app\/couchbase.service.ts<\/strong> e inclua o seguinte c\u00f3digo TypeScript:<\/p>\n<pre><code>import { Injectable } from \"@angular\/core\";\r\nimport { Couchbase } from \"nativescript-couchbase\";\r\n\r\n@Injectable()\r\nexport class CouchbaseService {\r\n\r\n    private database: any;\r\n    private pull: any;\r\n    private push: any;\r\n\r\n    public constructor() { }\r\n\r\n    public getDatabase() { }\r\n\r\n    public startSync(gateway: string, continuous: boolean) { }\r\n\r\n    public stopSync() { }\r\n\r\n}<\/code><\/pre>\n<p>Esse servi\u00e7o poder\u00e1 ser injetado em todas as p\u00e1ginas. Uma \u00fanica inst\u00e2ncia do Couchbase ser\u00e1 armazenada no diret\u00f3rio <code>banco de dados<\/code> e as informa\u00e7\u00f5es sobre os replicadores push e pull ser\u00e3o armazenadas em suas respectivas vari\u00e1veis.<\/p>\n<p>Dentro do <code>construtor<\/code> temos o seguinte:<\/p>\n<pre><code>public constructor() {\r\n    if(!this.database) {\r\n        this.database = new Couchbase(\"data\");\r\n        this.database.createView(\"profiles\", \"1\", function(document, emitter) {\r\n            emitter.emit(document._id, document);\r\n        });\r\n    }\r\n}<\/code><\/pre>\n<p>Antes de criar uma nova inst\u00e2ncia do Couchbase, verificamos se j\u00e1 n\u00e3o temos uma. Caso contr\u00e1rio, abrimos o banco de dados e criamos uma visualiza\u00e7\u00e3o MapReduce, que n\u00e3o \u00e9 nada que j\u00e1 n\u00e3o tenhamos visto nos exemplos anteriores.<\/p>\n<pre><code>public getDatabase() {\r\n    return this.database;\r\n}<\/code><\/pre>\n<p>Quando chegar a hora de obter essa inst\u00e2ncia, podemos retorn\u00e1-la por meio do <code>getDatabase<\/code> fun\u00e7\u00e3o. Isso nos leva \u00e0 replica\u00e7\u00e3o de dados.<\/p>\n<pre><code>public startSync(gateway: string, continuous: boolean) {\r\n    this.push = this.database.createPushReplication(gateway);\r\n    this.pull = this.database.createPullReplication(gateway);\r\n\r\n    this.push.setContinuous(continuous);\r\n    this.pull.setContinuous(continuous);\r\n\r\n    this.push.start();\r\n    this.pull.start();\r\n}<\/code><\/pre>\n<p>Para este exemplo, faremos uma sincroniza\u00e7\u00e3o bidirecional com uma inst\u00e2ncia do Sync Gateway. Temos a op\u00e7\u00e3o de sincronizar uma vez ou continuamente enquanto o aplicativo estiver aberto. Quando quisermos interromper a replica\u00e7\u00e3o, podemos usar a op\u00e7\u00e3o <code>stopSync<\/code> vista abaixo:<\/p>\n<pre><code>public stopSync() {\r\n    this.push.stop();\r\n    this.pull.stop();\r\n}<\/code><\/pre>\n<p>Como esse ser\u00e1 um servi\u00e7o compartilhado, ele precisa ser injetado no <code>@NgModule<\/code> bloco. Abra a se\u00e7\u00e3o <strong>app\/app.module.ts<\/strong> e inclua o seguinte TypeScript:<\/p>\n<pre><code>import { NgModule, NO_ERRORS_SCHEMA } from \"@angular\/core\";\r\nimport { NativeScriptModule } from \"nativescript-angular\/platform\";\r\nimport { NativeScriptFormsModule } from \"nativescript-angular\/forms\";\r\nimport { NativeScriptRouterModule } from \"nativescript-angular\/router\";\r\nimport { ModalDialogService } from \"nativescript-angular\/modal-dialog\";\r\n\r\nimport { appComponents, appRoutes } from \".\/app.routing\";\r\nimport { AppComponent } from \".\/app.component\";\r\nimport { ModalComponent } from \".\/app.modal\";\r\nimport { CouchbaseService } from \".\/couchbase.service\";\r\n\r\n@NgModule({\r\n    declarations: [AppComponent, ModalComponent, ...appComponents],\r\n    entryComponents: [ModalComponent],\r\n    bootstrap: [AppComponent],\r\n    imports: [\r\n        NativeScriptModule,\r\n        NativeScriptFormsModule,\r\n        NativeScriptRouterModule,\r\n        NativeScriptRouterModule.forRoot(appRoutes)\r\n    ],\r\n    providers: [ModalDialogService, CouchbaseService],\r\n    schemas: [NO_ERRORS_SCHEMA]\r\n})\r\nexport class AppModule { }<\/code><\/pre>\n<p>O exemplo acima \u00e9 o que vimos anteriormente, mas desta vez importamos o <code>CouchbaseService<\/code> e o injetou no <code>provedores<\/code> matriz do <code>@NgModule<\/code> bloco.<\/p>\n<p>Agora, cada uma de nossas p\u00e1ginas pode ser atualizada para usar o novo servi\u00e7o do Angular.<\/p>\n<h2 id=\"upgrading-the-nativescript-application-pages\">Atualiza\u00e7\u00e3o das p\u00e1ginas do aplicativo NativeScript<\/h2>\n<p>Temos duas p\u00e1ginas que precisam ser atualizadas para refletir nosso servi\u00e7o do Angular. Abra a se\u00e7\u00e3o <strong>app\/components\/profile-list\/profile-list.ts<\/strong> e remova o c\u00f3digo do Couchbase encontrado no arquivo <code>construtor<\/code> m\u00e9todo. Em vez disso, o arquivo deve se parecer com o seguinte:<\/p>\n<pre><code>import { Component, OnInit, OnDestroy, NgZone } from \"@angular\/core\";\r\nimport { Location } from \"@angular\/common\";\r\nimport { Router } from \"@angular\/router\";\r\nimport { CouchbaseService } from \"..\/..\/couchbase.service\";\r\n\r\n@Component({\r\n    selector: \"profile-list\",\r\n    templateUrl: \".\/components\/profile-list\/profile-list.html\",\r\n})\r\nexport class ProfileListComponent implements OnInit, OnDestroy {\r\n\r\n    public profiles: Array;\r\n    private database: any;\r\n\r\n    public constructor(private router: Router, private location: Location, private zone: NgZone, private couchbase: CouchbaseService) {\r\n        this.database = this.couchbase.getDatabase();\r\n        this.profiles = [];\r\n    }\r\n\r\n    public ngOnInit() {\r\n        this.location.subscribe(() =&gt; {\r\n            this.refresh();\r\n        });\r\n        this.refresh();\r\n    }\r\n\r\n    public refresh() {\r\n        this.profiles = [];\r\n        let rows = this.database.executeQuery(\"profiles\");\r\n        for(let i = 0; i &lt; rows.length; i++) {\r\n            this.profiles.push(rows[i]);\r\n        }\r\n    }\r\n\r\n    public create() {\r\n        this.router.navigate([\"profile\"]);\r\n    }\r\n\r\n}<\/code><\/pre>\n<p>Observe no exemplo acima que importamos <code>CouchbaseService<\/code> e o injetou no <code>construtor<\/code> juntamente com o m\u00e9todo <code>NgZone<\/code>. Em vez de obter o banco de dados e criar uma exibi\u00e7\u00e3o, precisamos apenas chamar o comando <code>getDatabase<\/code> fun\u00e7\u00e3o do nosso servi\u00e7o.<\/p>\n<p>At\u00e9 agora, nada de ruim, certo?<\/p>\n<p>Agora vamos abrir o arquivo <strong>app\/components\/profile\/profile.ts<\/strong> arquivo. Nesse arquivo, inclua o seguinte c\u00f3digo:<\/p>\n<pre><code>import { Component, ViewContainerRef } from \"@angular\/core\";\r\nimport { Location } from \"@angular\/common\";\r\nimport { ModalDialogService } from \"nativescript-angular\/directives\/dialogs\";\r\nimport { CouchbaseService } from \"..\/..\/couchbase.service\";\r\nimport { ModalComponent } from \"..\/..\/app.modal\";\r\n\r\n@Component({\r\n    selector: \"profile\",\r\n    templateUrl: \".\/components\/profile\/profile.html\",\r\n})\r\nexport class ProfileComponent {\r\n\r\n    public profile: any;\r\n    private database: any;\r\n\r\n    public constructor(private modal: ModalDialogService, private vcRef: ViewContainerRef, private location: Location, private couchbase: CouchbaseService) {\r\n        this.profile = {\r\n            photo: \"~\/kitten1.jpg\",\r\n            firstname: \"\",\r\n            lastname: \"\"\r\n        }\r\n        this.database = this.couchbase.getDatabase();\r\n    }\r\n\r\n    public showModal(fullscreen: boolean) {\r\n        let options = {\r\n            context: { promptMsg: \"Pick your avatar!\" },\r\n            fullscreen: fullscreen,\r\n            viewContainerRef: this.vcRef\r\n        };\r\n        this.modal.showModal(ModalComponent, options).then((res: string) =&gt; {\r\n            this.profile.photo = res || \"~\/kitten1.jpg\";\r\n        });\r\n    }\r\n\r\n    public save() {\r\n        this.database.createDocument(this.profile);\r\n        this.location.back();\r\n    }\r\n\r\n}<\/code><\/pre>\n<p>Com exce\u00e7\u00e3o de <code>NgZone<\/code>Na p\u00e1gina anterior, fizemos a mesma altera\u00e7\u00e3o no Couchbase que fizemos na p\u00e1gina anterior. Veremos o que <code>NgZone<\/code> em breve.<\/p>\n<p>Nesse ponto, podemos prosseguir com a configura\u00e7\u00e3o do Sync Gateway para preparar a sincroniza\u00e7\u00e3o de dados.<\/p>\n<h2 id=\"building-the-sync-gateway-replication-configuration\">Cria\u00e7\u00e3o da configura\u00e7\u00e3o de replica\u00e7\u00e3o do Sync Gateway<\/h2>\n<p>Voc\u00ea j\u00e1 deve ter feito o download de <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/downloads\/\">Gateway de sincroniza\u00e7\u00e3o do Couchbase<\/a> at\u00e9 agora. Com ele instalado, precisamos criar um arquivo de configura\u00e7\u00e3o para o nosso projeto. A seguir, um exemplo de uma configura\u00e7\u00e3o muito simples:<\/p>\n<pre><code>{\r\n    \"log\":[\"CRUD+\", \"REST+\", \"Changes+\", \"Attach+\"],\r\n    \"databases\": {\r\n        \"example\": {\r\n            \"server\":\"walrus:\",\r\n            \"sync\":`\r\n                function (doc) {\r\n                    channel (doc.channels);\r\n                }\r\n            `,\r\n            \"users\": {\r\n                \"GUEST\": {\r\n                    \"disabled\": false,\r\n                    \"admin_channels\": [\"*\"]\r\n                }\r\n            }\r\n        }\r\n    }\r\n}<\/code><\/pre>\n<p>A configura\u00e7\u00e3o acima pode ser salva em um arquivo chamado <strong>sync-gateway-config.json<\/strong> ou similar. Essencialmente, ele usa um armazenamento na mem\u00f3ria chamado <code>morsa:<\/code> com um nome de banco de dados de <code>exemplo<\/code>. N\u00e3o h\u00e1 permiss\u00f5es de leitura ou grava\u00e7\u00e3o em nosso exemplo. Todos os dados ser\u00e3o sincronizados em todas as plataformas e dispositivos.<\/p>\n<p>Conectar o Sync Gateway ao Couchbase Server \u00e9 t\u00e3o simples quanto alterar <code>morsa:<\/code> para o host de sua inst\u00e2ncia do Couchbase Server.<\/p>\n<p>Para executar o Sync Gateway a partir da linha de comando, voc\u00ea deve executar:<\/p>\n<pre><code>\/path\/to\/sync_gateway \/path\/to\/sync-gateway-config.json<\/code><\/pre>\n<p>Ele criar\u00e1 um painel que pode ser acessado em https:\/\/localhost:4985\/_admin\/. No n\u00edvel do aplicativo, ele usar\u00e1 a porta 4984.<\/p>\n<h2 id=\"including-synchronization-logic-for-couchbase-and-nativescript\">Incluindo a l\u00f3gica de sincroniza\u00e7\u00e3o para Couchbase e NativeScript<\/h2>\n<p>Tudo est\u00e1 completo na prepara\u00e7\u00e3o da replica\u00e7\u00e3o de dados em nosso aplicativo. A replica\u00e7\u00e3o de dados nos permitir\u00e1 usar ouvintes de altera\u00e7\u00f5es para atualizar nossa interface do usu\u00e1rio conforme necess\u00e1rio.<\/p>\n<p>Abra o arquivo <strong>app\/components\/profile-list\/profile-list.ts<\/strong> e inclua o seguinte no <code>ngOnInit<\/code> m\u00e9todo:<\/p>\n<pre><code>public ngOnInit() {\r\n    this.location.subscribe(() =&gt; {\r\n        this.refresh();\r\n    });\r\n    this.couchbase.startSync(\"https:\/\/192.168.57.1:4984\/example\", true);\r\n    this.database.addDatabaseChangeListener((changes) =&gt; {\r\n        for (let i = 0; i &lt; changes.length; i++) { let document = this.database.getDocument(changes[i].getDocumentId()); this.zone.run(() =&gt; {\r\n                this.profiles.push(document);\r\n            });\r\n        }\r\n    });\r\n    this.refresh();\r\n}<\/code><\/pre>\n<p>Quando o <code>ngOnInit<\/code> iniciamos a sincroniza\u00e7\u00e3o com nosso Sync Gateway em execu\u00e7\u00e3o local. Sinta-se \u00e0 vontade para definir o nome do host para o que for mais adequado para voc\u00ea. Depois de iniciarmos a sincroniza\u00e7\u00e3o, configuramos nosso ouvinte de altera\u00e7\u00f5es para enviar as altera\u00e7\u00f5es para o nosso <code>perfis<\/code> array. Como se trata de um ouvinte, precisamos usar <code>NgZone<\/code> caso contr\u00e1rio, ele n\u00e3o ser\u00e1 refletido na interface do usu\u00e1rio.<\/p>\n<p>O exemplo acima \u00e9 apenas um exemplo simples em que adicionamos todas as altera\u00e7\u00f5es. Na realidade, voc\u00ea precisar\u00e1 verificar se os dados foram alterados, criados ou exclu\u00eddos. Todos os cen\u00e1rios viriam por meio da fun\u00e7\u00e3o <code>addDatabaseChangeListener<\/code>.<\/p>\n<p>Quando o aplicativo for interrompido, queremos interromper a sincroniza\u00e7\u00e3o de forma graciosa. Na se\u00e7\u00e3o <code>ngOnDestroy<\/code> inclua o seguinte:<\/p>\n<pre><code>public ngOnDestroy() {\r\n    this.couchbase.stopSync();\r\n}<\/code><\/pre>\n<p>A replica\u00e7\u00e3o para o Couchbase Sync Gateway ser\u00e1 interrompida quando o m\u00e9todo Angular acima for chamado.<\/p>\n<h2 id=\"conclusion\">Conclus\u00e3o<\/h2>\n<p>Neste tutorial, voc\u00ea viu como adicionar suporte de sincroniza\u00e7\u00e3o ao seu aplicativo m\u00f3vel Angular NativeScript. Essa foi a terceira parte de tr\u00eas da s\u00e9rie de tutoriais. Anteriormente, vimos como fazer <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/key-value-operations-in-couchbase-mobile-via-nativescript-and-angular\/\">opera\u00e7\u00f5es b\u00e1sicas do Couchbase para salvar e carregar dados<\/a> bem como <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/querying-for-couchbase-documents-in-a-nativescript-angular-mobile-application\/\">consulta de documentos<\/a>. Data no desenvolvimento de aplicativos m\u00f3veis usando estruturas como <a href=\"https:\/\/www.nativescript.org\">NativeScript<\/a> e o Angular devem ser f\u00e1ceis. Ser capaz de armazenar objetos JavaScript e dados JSON em um banco de dados NoSQL e sincroniz\u00e1-los \u00e9 um grande fardo para o desenvolvedor.<\/p>","protected":false},"excerpt":{"rendered":"<p>Over the past few days we&#8217;ve been exploring how to create a simple Android and iOS application using NativeScript, Angular and Couchbase. First we saw how to use Couchbase for basic key-value operations and then we saw how to query [&hellip;]<\/p>","protected":false},"author":63,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1815,1810,9327,2366],"tags":[1704,1543,1589,1562],"ppma_author":[9032],"class_list":["post-2490","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-mobile","category-javascript","category-sync-gateway","tag-angular","tag-javascript","tag-nativescript","tag-replication"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.3 (Yoast SEO v26.3) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular - The Couchbase Blog<\/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\/blog\/pt\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular\" \/>\n<meta property=\"og:description\" content=\"Over the past few days we&#8217;ve been exploring how to create a simple Android and iOS application using NativeScript, Angular and Couchbase. First we saw how to use Couchbase for basic key-value operations and then we saw how to query [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\" \/>\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=\"2017-01-11T15:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:15:27+00:00\" \/>\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=\"8 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\"},\"author\":{\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\"},\"headline\":\"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular\",\"datePublished\":\"2017-01-11T15:00:00+00:00\",\"dateModified\":\"2025-06-14T03:15:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\"},\"wordCount\":1126,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"Angular\",\"javascript\",\"nativescript\",\"replication\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Mobile\",\"JavaScript\",\"Sync Gateway\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\",\"name\":\"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2017-01-11T15:00:00+00:00\",\"dateModified\":\"2025-06-14T03:15:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular\"}]},{\"@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\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1\",\"name\":\"Nic Raboy, Developer Advocate, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354\",\"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":"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular - The Couchbase Blog","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\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/","og_locale":"pt_BR","og_type":"article","og_title":"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular","og_description":"Over the past few days we&#8217;ve been exploring how to create a simple Android and iOS application using NativeScript, Angular and Couchbase. First we saw how to use Couchbase for basic key-value operations and then we saw how to query [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/","og_site_name":"The Couchbase Blog","article_author":"https:\/\/www.facebook.com\/thepolyglotdeveloper","article_published_time":"2017-01-11T15:00:00+00:00","article_modified_time":"2025-06-14T03:15:27+00:00","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":"8 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/"},"author":{"name":"Nic Raboy, Developer Advocate, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1"},"headline":"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular","datePublished":"2017-01-11T15:00:00+00:00","dateModified":"2025-06-14T03:15:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/"},"wordCount":1126,"commentCount":4,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["Angular","javascript","nativescript","replication"],"articleSection":["Best Practices and Tutorials","Couchbase Mobile","JavaScript","Sync Gateway"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/","url":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/","name":"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2017-01-11T15:00:00+00:00","dateModified":"2025-06-14T03:15:27+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/syncing-couchbase-documents-between-mobile-platforms-and-devices-with-nativescript-and-angular\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Syncing Couchbase Documents Between Mobile Platforms and Devices with NativeScript and Angular"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"Blog do Couchbase","description":"Couchbase, o banco de dados NoSQL","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":"Blog do Couchbase","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\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/bb545ebe83bb2d12f91095811d0a72e1","name":"Nic Raboy, defensor dos desenvolvedores, Couchbase","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/8863514d8bed0cf6080f23db40e00354","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 \u00e9 um defensor das modernas tecnologias de desenvolvimento m\u00f3vel e da Web. Ele tem experi\u00eancia em Java, JavaScript, Golang e uma variedade de estruturas, como Angular, NativeScript e Apache Cordova. Nic escreve sobre suas experi\u00eancias de desenvolvimento relacionadas a tornar o desenvolvimento m\u00f3vel e da Web mais f\u00e1cil de entender.","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\/"}]}},"authors":[{"term_id":9032,"user_id":63,"is_guest":0,"slug":"nic-raboy-2","display_name":"Nic Raboy, Developer Advocate, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/bedeb68368d4681aca4c74fe5f697f0c423b80d498ec50fd915ba018b72c101f?s=96&d=mm&r=g","author_category":"","last_name":"Raboy","first_name":"Nic","job_title":"","user_url":"https:\/\/www.thepolyglotdeveloper.com","description":"Nic Raboy \u00e9 um defensor das modernas tecnologias de desenvolvimento m\u00f3vel e da Web. Ele tem experi\u00eancia em Java, JavaScript, Golang e uma variedade de estruturas, como Angular, NativeScript e Apache Cordova. Nic escreve sobre suas experi\u00eancias de desenvolvimento relacionadas a tornar o desenvolvimento m\u00f3vel e da Web mais f\u00e1cil de entender."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/2490","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=2490"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/2490\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=2490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=2490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=2490"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=2490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}