How to Use couchDB as local storage in android application - database

I am developing an app, which is in android.
In my app I want to use couchdb database for storing and sync purpose.
which will work offline too.
so, how to create couchDB database first and then insert data in that database, so that my application will use the couchDB database as local storage like SQLite.
I have aleready went through many links but they are not satisfying my need.
So Please provide some guide line or an help or comment or sample code to performed that operation.

CouchDb and Couchbase Lite are very close in terms of usage. If you are looking for an easy way to sync and store data locally on your android device I would recommend looking at Couchbase Lite for Android.
https://github.com/couchbase/couchbase-lite-android

Related

Hybrid Apps: which DB strategy "PouchDB+CouchDB" Or Couchbase Mobile?

Context
I'm developing a hybrid/mobile app using Cordova. This app displays content, such as news, magazine articles and weather info that is dynamically generated and delivered via a Web App (self-hosted developed with PHP). In order to decide which mobile devices "get" which content, I need to constantly keep track of the history of displays on each device, and gather information such as : article name, display date/time, location(lat/lon), etc.
The BIG problem I have is...
Now, because the data that I'm gathering is unstructured, I first tried with Firebase (Google), which allowed me to easily gather all the data, in real-time using a key:value schema and then retrieve my data on the webapp running another JS script. The problems with this solution are:
Querying possibilities are too limited.
I'm not comfortable leaving all my data handled by Google (Nothing against Google, butI'd prefer to own my data).
The Question
What are the storage strategies that I could use ? I've been reading a lot about Redis, Parse-server, PouchDB+CouchDB, and MongoDB, but I got lost in a world of information about NoSql databases, and now I really do not know what to do :'(
I've always used relational databases for my projects (Mysql, MariaDB), but I'm not afraid in getting my hands dirty with NoSQL databases, however I'd appreciate if anyone can point me to the easiest-to-implement solution.
EDIT (17/04/18)
I think I narrowed down my question to 2 options
PouchDB + CouchDB, or
Couchbase Mobile = Couchbase Lite + Sync Gateway
Can anyone, please give me some feedback with regards to these two options? Ease of implementation, Querying, maintenance, etc ?
Thanks!
Figured, I should probably explain my earlier comment better.
Couchbase Mobile = Couchbase Lite (runs on mobile device) + Sync Gateway + Couchbase Server (hosted in backend)
W.r.t your first concern
Querying possibilities are too limited.
Couchbase Server supports N1QL - which is a superset of SQL for NoSQL. So you should be able to do the kind of extensive querying that you want w/ Couchbase Server.This link discusses how you can do geospatial queries (since you mentioned that as a use case)
W.r.t your second concern
I'm not comfortable leaving all my data handled by Google (Nothing
against Google, butI'd prefer to own my data).
With Couchbase Mobile, you have control over where the data is hosted - you have the option of persisting the data in Couchbase servers that you can host in private/public cloud (AWS, Azure, GCP).
Note on Cordova support in Couchbase Lite:
It is supported as a community project in Couchbase Lite 1.4. However, in the latest 2.0 release, you will have to develop your Cordova plugin on top of the native API .

What is a good DB for Offline/Online capabilities for a Web Application

My team is developing an appraisals software for real estate on an enterprise level. This application has some special requirements.
The application should work in Online and Offline environment. If the user is working and suddenly Application goes offline User should be able to work offline. All offline work is stored in local database and sync next time to a central database when Application connects to the internet.This application has many users and all will work at the same time on same information.
User local database must be updated all times either other users are working or not. If other users are working all updated information should be available in the local database to ensure when the user goes offline all information is updated.
The question is How to develop this kind of application? Is there any standard way to achieve this target? Is there any standard or non-standard pattern to build this kind of software?
We are planning to use the Angular 2 Framework for our front end development. If anyone has experience with this and can give suggestions on what tech stack we should use, it would be greatly appreciated.
Well, you can use pouchdb as client-side DB and use every DB that uses the CouchDB sync protocol. I have used this stack with an Angular 2 application. (NoSQL)
I also worked with Kinto (PostgreSQL) and Kinto.js. It is not as user-friendly as PouchDB, but I think the documentation has improved since I used it.
And finally, I know about Meteor/Mongo/GroundDB. Meteor is very powerful it's a fully reactive Stack which works really well with the async options you have with angular and rxjs. But think if you have not worked with rxjs or reactive backends it's the hardest to learn. I took me a long time to adapt my coding style to the reactive Behavior of the data flow.
We are also doing an online POS that would work as a point of sale
but we are in constant backend solution for us to set up database that can sync or scale with offline and online .

how to use Couchbase as a database in the cloud?

I need to make a database stored in the cloud for an application. i just need to store and retrieve images from that database to the application. i found Couchbase and i think that's the way to go for me, but im not really sure of how to start.
I suppose that if i want to use Couchbase as a database i need to install it in my computer and it will use my computer as the server. but i need to do that on the cloud, because i don't have a computer that i could use 24/7 as a server. so im not really sure of how i could install Couchbase in the cloud.
I have the vague idea (from reading the AWS page) that some hosting servers out there have the option of using them as a computer where i can install linux or any other operative system, and then install couchbase there, but im not really sure if that's true.
So, if that's the case, is there any cloud (or web) hosting service that you recomend that could do what i need? it would be better if its free, because its a class project, but i don't mind if its paid if it has a 30/60/90 days of free trial. could amazon's AWS or HP's Helion Eucalyptus do the job?
How do i install the Couchbase database in that hosting service?
If using Couchbase in the cloud doesn't work like i think it works, how can i do what i need?
I'm really confused, thank you in advance.
You are correct that you need a server (somewhere) and just install Couchbase server on it by following the Couchbase instructions.
Or you could use the AWS prebuilt version.
Using a database to store images (or any large binary data) is usually a terrible idea. They already invented a database for storing files - it's called a filesystem.
Glib replies aside, you really should consider using the built-in mechanisms you get from cloud providers for storing binary objects; if you're using AWS, then S3 would be my first choice. You get all the benefits of a distributed database: reliability, scalability, etc., but without the unnecessary complexity of using a database for something as simple as storing binary blobs. Some further reading on using S3 for object storage: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingObjects.html
Now, there are some use-cases where it might make sense to use Couchbase for storing images, mostly if you need the high performance that you get from the built-in cache in Couchbase to retrieve the images very quickly. In such a case, here is a short list of steps to get you started:
Sign up for the AWS free tier: https://aws.amazon.com/free/
Get set up for AWS EC2: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html
Follow the getting started guide to create an AWS VM instance: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html
Install Couchbase: http://developer.couchbase.com/documentation/server/4.0/getting-started/installing.html

What is a cross platform solution to keep my mobile app updated from a database?

Alrighty I have a cross platform mobile app built using xamarin and the mvvmcross framework. Part of the app is grabbing some data from a remote database. This data will be updated/deleted/created occasionally and i want to keep my users up-to-date. What's a good way to achieve this, preferably using cross platform code?
I can always set some kind of timer but I would much prefer a more elegant way.
Couchbase, as mentioned by Artur, is a great option - especially if doing disconnected editing. It does have a bit of a learning curve picking it up from scratch (which is totally worth it if you press on).
Consider Akavache (https://github.com/akavache/Akavache) as an alternative. It's well used and simpler but provides the basic capabilities you are asking about.
I recommend combining either approach with using ModernHttpClient (https://components.xamarin.com/view/modernhttpclient) which is basically just a drop-in component that gets you a performance boost.
Check out this excellent article by Rob Gibbens that covers using Akavache, ModernHttpClient, and other x-platform wholesome goodness: http://arteksoftware.com/resilient-network-services-with-xamarin/.
Check out Couchbase Mobile
http://www.couchbase.com/nosql-databases/couchbase-mobile
There is a wrapper for Xamarin
https://components.xamarin.com/view/couchbase-lite-net
With Couchbase you can save/update/synchronize data between your mobile device and cloud server using NoSQL DB.
In the context of Couchbase Mobile for your use-case where you are updating/deleting and creating your data occasionally, you can replicate the data based on per method invocation. This would happen once as oppose to replication that is on a continuous basis.
You would do this by defining the logic on when your PUSH and PULL replication would occur on a particular database endpoint.
---PUSH Replication would be from your mobile app/device to Couchbase Server(Cloud component)
The library, Couchbase Lite (app component), on your app/device would flag new data or changes on existing documents(database) and will PUSH replicate to the Sync Gateway (data orchestration component).
---PULL Replication happens from the Couchbase Server(Cloud component) to mobile device. The Sync Gateway (data orchestration component) has advanced listeners that are observing for changes in the Couchbase Server and upon remote changes will pull data to the Sync Gateway and then update your mobile app/device.
I also suggest taking a look at the mini-hack quick tutorial, specifically the Xamarin one on how to get a Xamarin app working with Couchbase Mobile. And the mobile Developer Portal is a another great resource too where there are Xamarin Android & iOS guides.

Best methods for developing on/from a cloud server?

I recently landed myself on a project that, like most projects today, relies on multiple relational databases and also, like most projects today, relies on the flexibility and security of cloud computing.
I got into cloud services a little over a month ago and since then I've tackled the basics of most the services that Amazon Web Services offers but have only tested and deployed personal projects.
Now I will be working on a clients server and its a hefty instance, therefore I need to research the best method for developing a pre-existing application on a cloud server. Also bare in mind that the data stored in the databases is also being updated 'live'/dynamically.
I assume it's still good practise to take a local copy to work on? In that case, is the best method to download the whole server using ssh? If so, are there any alternatives? I feel that just downloading the whole server and setting it all back up bit by bit (including the data 'stream') will be very time consuming for such a big application connected to such big databases.
Is there something a little more elegant?
If you are working on a cloud environment you may have developement environment.
You may have a local repository but nothing more than your IDE and your versionning tool.
All your service might be provided by the cloud and the most efficient way to test you code is to do it on a target Image.
personally ,I use cloud foundry or IBM Bluemix with my git repository. I push directly the modifications when i want to test.
you can use cloud services,you dont have to think about server setup/services.you will just need a repository like git.
you can follow below sample link for getting started on configuration on bluemix:
https://hub.jazz.net/tutorials
https://www.facebook.com/ibmswg?ref=hl&ref_type=bookmark

Resources