Versioning in couchbase / Couchbase Lite

Hi there,
I was looking for version controlling in couchbase Lite or in couchbase server.
I founded some docs on couchbase officials , which says that we need to implement some sort of logic for maintaining versions by storing old documents. i was trying the same. but it’ll costly when data is much bigger and keeps on changing. So is there any other way to maintain versioning of the document ?

Couchbase Lite is not a version control system. Old revisions will be pruned or compacted away. So it is the responsibility of the application to maintain history of documents if they need it. So you would treat each new version of document that you want to save as a separate document (you include a rootId and versionID property that will link the document versions) . That way they won’t get purged by the system during pruning/compaction.
You could consider optimizing storage by only storing the properties that have changed since the previous version and have logic to merge the version properties. And also, you should have a history limit so you delete documents prior to a certain version so your db does not bloat indefinitely
If you are interested, you can learn more about Pruning/ Compaction in CBM here