I want Couchbase to first temporary store the data, and then automatically sync it with Server. How do I achieve this ?
For example, In note-making app, I add a note and Couchbase should automatically add it to the Server.
You're in luck! The requirement you've described is exactly how Couchbase Mobile works.
Couchbase Mobile is comprised of two parts:
Couchbase Lite: A stand-alone embedded database that you can use directly within your mobile app.
Sync Gateway: a synchronization mechanism that securely syncs data between mobile clients and server.
So, back to your question. In order to achieve what you're looking for you would first create an instance of your Couchbase Lite database. From there, as you would expect, you can perform basic CRUD operations, query data, etc. You can find more information on the built-in capabilities here:
iOS (Swift)
iOS (Obj-C)
Android (Java)
Xamarin (C#)
Once you've created an embedded database you can start replication (synchronization) on it by using the Sync Gateway integration that comes with the Couchbase.Lite and Couchbase.Lite.Enterprise SDK component for iOS, Android, or Xamarin.
I recommend checking out the following tutorials for using Couchbase Lite and Sync Gateway:
iOS: Data Sync Fundamentals
Android: Data Sync Fundamentals
Xamarin: Data Sync Fundamentals
You are looking for the Couchbase Sync Gateway: https://docs.couchbase.com/sync-gateway/2.1/index.html
Related
It's possible to connect an Android application directly to a Couchbase server database?.
It's possible to get a Document from Couchbase's bucket and use it from an Android application?.
Thank you.
tl;dr: Use Sync Gateway.
Couchbase Sync Gateway is designed to be a web edge service that you use to access data. In the most typical scenario Sync Gateway connects to a back end Couchbase Server cluster.
You could in theory use one of the client libraries to access Couchbase Server directly. You really don't want to do this for several reasons.
The client libraries have different expectations around network latency and availability.
They don't currently (as of Couchbase Mobile 1.4) support the meta data needed for syncing.
You'd need to expose your server which raises your security risk profile
The system architecture has all this in mind, which is why it's designed the way it is.
I made an android application which is collecting data from a wearable device and storing it into a local sqlite database.
Now I want to sync the data of all android devices local sqlite databases to cloud and visualize the data and perform data analytics related operations on it.
Can anyone suggest me what to do?
I have looked around multiple clouds like AWS, GAE, AZURE, HEROKU, GoDadddy shared cloud etc for storing my data in a central database.
My question is that should I directly store data from android into mysql or some other database using jdbc or odbc driver or write a webservice or api for storing data in cloud?
I want to sync data after some time interval i.e. a day or so, between local android device and cloud.
According to your description, based on my understanding, you want to sync up the data from wearable device between all android devices and cloud.
Per my experience, the way to directly store data from android into database is not a good choice. The normal way is creating a web service or rest apis to communicate with mobile device for data synchronizing to cloud.
On Azure, the best practice for your needs is that creating an Azure Mobile App instance and enable the Offline Data Sync feature in Azure Mobile Apps to implement this. You can refer to the Azure offical document Offline Data Sync in Azure Mobile Apps to know the related concept.
You can get start with the tutorial for Android within Azure Mobile Apps, and then continous to the next tutorial to implement the feature of offline sync up data automatically.
As reference, the tutorial How to use the Android client library for Mobile Apps will shows you how to use the Android client SDK for Mobile Apps to access the data from SQL Azure table online.
Meanwhile, to visualize the data and perform data analytics related operations on the cloud data, Azure support more Intelligence + Analysis services which could be used for your future plan.
I've built an Android app based on Couchbase Lite which talks to a Couchbase Database via Sync Gateway. I've now tried to get Couchbase Lite to replicate with a CouchDB 2.0 database, but I am getting the following error:
W/RemoteRequest: com.couchbase.lite.replicator.RemoteRequest {POST,
http://192.168.1.5:5984/_revs_diff}: Got error status: 404 for
http://192.168.1.5:5984/_revs_diff. Reason: Object Not Found
W/Sync: PusherInternal{http://192.168.1.5:5984, push, 12ff9}: Progress:
set error =com.couchbase.lite.replicator.RemoteRequestResponseException:
Object Not Found
Note that for this I am not going through Sync Gateway but rather point Couchbase Lite directly to the CouchDB Url.
I don't know whether I need to go through Sync Gateway or not, but my impression after reading the Couchbase docs on Couchbase lite is that I do not when connecting to a CouchDb database and this post seems to back that up. https://github.com/couchbase/sync_gateway/issues/312
Can someone please confirm whether it is possible for couchbase lite to replicate directly with a CouchDb 2.0 database and if so what is the correct way to set it up?
Also, the app will be used by many sites, a site can be made up of one or more users. The reason I was thinking switching to CouchDb is so that I can have one database per site, something which doesn't seem to be easily doable in Couchbase. However, I have now discovered Channels in Couchbase which allow me to use one database but keep access to documents restricted by site (i.e. a site could have many users and all users should have access to all documents for that site).
What would be the pros and cons of using either separate databases in CouchDb or channels in Couchbase?
Thanks.
As #Hod said different buckets is equivalent to different databases in Couch DB so you can go for that.
Secondly it is definitely encouraged to use sync_gateway's channels property if you can because creating single bucket is preferred over multiple buckets and I have used sync_gateway with couch Lite and Couch server, it works perfectly fine and also with accuracy so I think you should go with sync_gateway and channels instead of creating multiple buckets
A few points in response:
The main thing is I think you can do what you want easily in Couchbase. Buckets in Couchbase Server are somewhat equivalent to separate databases. So you could split your sites that way. Channels in Sync Gateway give you more control for separating data and controlling access, as you've seen.
Couchbase Lite should be able to sync with CouchDB, but this isn't heavily tested. It's hard to tell from your snippet what's going wrong. You might check this post for some ideas: CouchDB: how to use _revs_diff to get document revision ID
Sync Gateway exposes a sort of superset of the CouchDB replication endpoints, so you'll have more flexibility using Couchbase Lite with Sync Gateway.
So I have an app that I want to build, and it needs a sync feature. The basic premise of the app is that the user will be able to store some tabulated data in it. I then want to be able to upload and store that data to a server so they can sync it across devices.
As the question states, it needs to be cross-platform, specifically Cordova. I was thinking about using a MySQL database with tables for each user's data. Then use calls on that user-specific table to sync and retrieve data. Are there any drawbacks to that approach? Better ways of handling it?
Take a look at CouchDB (server) and PouchDB (client). Syncing is made quite easy in these databases.
PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser.
PouchDB was created to help web developers build applications that work as well offline as they do online.
It enables applications to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.
It is:
Cross Browser: Works in Firefox, Chrome, Opera, Safari, IE and Node.js
Lightweight: PouchDB is just a script tag and 46KB (gzipped)
Easy to Learn: Requires some programming knowledge, however PouchDB is a piece of cake to learn.
Open Source: Everything is developed out in the open on Github, contributors always welcome!
See this SO question and answer to get more in-depth of the architecture of using PouchDB/CouchDB.
I am struggling to differentiate between all of the different couch* technologies that are out there. I've been flip-flopping between using CouchDB and using Couchbase Server for an Android game that I'm developing and the lack of documentation is frustrating.
My understanding of the technologies:
CouchDB - A no-SQL database that has been under development for the last few years and is communicated with using a RESTful API. It has
been abandoned by its chief developers in favor of working on
Couchbase Server.
Couchbase Server - An enterprise solution to a large database where low-latency is paramount. It keeps 'hot' data in memory using
memcached but data is persisted to a CouchDB database.
Couchbase Mobile - A mobile implementation of CouchDB <--Legacy
TouchDB - A mobile implementation of CouchDB.
Ektorp - A framework that allows a developer to talk to and sync with a CouchDB instance from Java.
What's missing in my list is a framework to talk to Couchbase Server from Android (and eventually iOS).
Does such a framework exist?
I'm assuming that you don't want Couchbase Server on Android, but rather you want to have your Android app talk to a Couchbase Server instance on a remote server somewhere.
The primary interface for Couchbase Server is memcached, and so any memcached library for Android will work. If needed, any of the remaining Couch calls are simple HTTP calls.
To sync an application to Couchbase Server, typically an application built atop TouchDB, the framework you're seeking is Mobile Syncpoint as listed on the Couchbase wiki. It's an Open Source work in progress, but coordinates for dev mailing lists, and concepts link off of that wiki.
Typically you'd use Ektorp atop TouchDB, then use Mobile Syncpoint to sync to Couchbase Server running in a datacenter somewhere.