Jeav148
Jeav148

Reputation: 13

CouchDB data syncing/downloading

I’m building a new mobile application and intend to use Apache CouchDB and Couchbase Lite to implement an offline/online data syncing model. A basic CRUD is completed and working.

My question is about how much of the data is synced. Example:

The centralized database has data of 3 users. Lets say each user creates 100Mb of data that is syncronized in the server.

Data created by each user is unnaccesible for other users, and the queries that are made from the mobile client never include the data of other users.

If a user only queries and creates its own data, will he have in his device 300Mb of data or only his own 100Mb?

Upvotes: 1

Views: 1539

Answers (1)

Juanjo Rodriguez
Juanjo Rodriguez

Reputation: 2121

I assume you have a single database in the CouchDB server where the 3 users are replicanting their local database. In this case:

  • If you perform push replications from mobile device to the server only its own data is in the local Couchbase lite database.

  • If you also perform pull replications from server to the mobile device, the local Couchbase lite database will have the complete server database (the data for the 3 users)

CouchDB can help you with this as it has support for filtered replications. In this case, you can use a parametrized filter function that allows you to replicate to each user's device its own data.

I'm not sure that Couchbase Lite supports filtered replication as it is focused on the Couchbase Sync Gateway.

I can confirm that Cloudant Sync supports the filtered replication based on filter functions and mango queries.

Filter functions can lead you into a performance problem if your db grows. Mango query selectors are a more perfomant solution for db filtering.

Upvotes: 2

Related Questions