2

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.

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
miPlodder
  • 795
  • 8
  • 18

2 Answers2

5

You're in luck! The requirement you've described is exactly how Couchbase Mobile works.

Couchbase Mobile is comprised of two parts:

  1. Couchbase Lite: A stand-alone embedded database that you can use directly within your mobile app.
  2. 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:

  1. iOS (Swift)
  2. iOS (Obj-C)
  3. Android (Java)
  4. 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:

  • Is it necessary to store data firstly in Couchbase Lite and then do the Syncronization process, or simply syncronization can be done ? – miPlodder Aug 01 '19 at 19:59
  • 1
    It's not a requirement to use Couchbase Lite in order to take advantage of Sync Gateway. Sync Gateway provides both public and admin API's that allow you to integrate using other storage options; https://docs.couchbase.com/sync-gateway/2.5/rest-api.html. – Robert Hedgpeth Aug 02 '19 at 20:07
  • Isn't it possible to have multiple tables inside a DB in Couchbase Lite (like here, http://localhost:4985/_admin/db/db) ? – miPlodder Aug 05 '19 at 01:27
  • Is there any online public chat channel like Gitter, which is active as I have several more questions i have to ask as the docs are not fully helpful ? – miPlodder Aug 05 '19 at 03:34
  • There's no concept of tables within the Couchbase Lite database. You can, however, have multiple documents inside of a Couchbase Lite database, if that's what you mean. Couchbase Lite is a Document-based NoSQL database. https://en.wikipedia.org/wiki/Document-oriented_database. You can take a close look at the Admin API capabilities here: https://docs.couchbase.com/sync-gateway/2.1/admin-rest-api.html#/database. – Robert Hedgpeth Aug 05 '19 at 16:42
  • @miPlodder Feel free to reach out to Couchbase on Gitter at https://gitter.im/couchbase/discuss. Also, https://forums.couchbase.com/ is another good resource. For the documentation we'd be very interested in gaining feedback from you on how we can improve it. Please feel free to submit feedback within https://docs.couchbase.com/home/index.html or contact me directly. – Robert Hedgpeth Aug 05 '19 at 17:02
  • How do I distinguish different type of Documents using Couchbase REST API (if I store different kinds of Documents in single Database), or do we have to create a different type of Databases for a different type of Documents? – miPlodder Aug 11 '19 at 04:24
  • 2
    @miPlodder The most common approach for this is to add "type" field to the document then give it a unique description (string). – Robert Hedgpeth Aug 13 '19 at 15:00
  • Is it mandatory to have a field name as `type`, can we use some another field name for example, like `table` instead of `type`? – miPlodder Aug 17 '19 at 08:10
  • Where can I contact you, Gitter or any other platform? – miPlodder Aug 18 '19 at 10:38
  • 1
    @miPlodder You can contact me directly at robert.hedgpeth@couchbase.com, on GitHub "rhedgpeth", or on Twitter (at)probablyrealrob. – Robert Hedgpeth Aug 19 '19 at 16:55
0

You are looking for the Couchbase Sync Gateway: https://docs.couchbase.com/sync-gateway/2.1/index.html

G. Blake Meike
  • 6,615
  • 3
  • 24
  • 40