Tiago A.
Tiago A.

Reputation: 2586

Does couchdb/pouchdb replicate work at a sub-document level?

I am using couchdb to store content of courses (text, attachments) that will sync with a mobile app with pouchdb. This content will change from time to time, and I want to use the replication mechanism to send the updated content to the mobile devices.

I have two options here:

  1. Should I store the whole content of the course in a single document? If I do so, will the whole document be transmitted over the network even when just a small part changes?
  2. Should I break the course in smaller documents (e.g. course > modules > lessons -> content blocks) so that smaller chunks of information are sent over the internet?

What is the best option?

Upvotes: 1

Views: 229

Answers (1)

Dale Harvey
Dale Harvey

Reputation: 1213

For attachments, CouchDB will do sub document updates, PouchDB will not although that is being worked on for PouchDB.

For any of the data not stored in attachments, the rest of the JSON neither do sub document level updates, so every change will transfer the entire JSON across.

If you are looking to minimise the amount of data that gets transferred on changes and are not worried about atomic changes to the course as a whole. Then splitting it out into a few documents sounds like a decent idea.

Upvotes: 2

Related Questions