I have an app using Couchbase Lite syncing with an instance of Couchbase server.
The total size of the database is around 40MB, therefore I was wondering if there’s a way to avoid downloading the whole database from scratch when the app is launched for the first time.
Is it possible to embed a pre-built version of the database in the app?
If so, the app will be syncing only the changes made after the pre-built version of the database was exported.
That would dramatically reduce the amount of data to be exchanged between the app and the server.
Hi @househippo, if I understood well, the pre-built database should be in CBL format, right? If so, how can I export a database currently stored on Couchbase server into a CBL file?
Most people have a UAT or Pre-prod build of an App that pulls the PROD data onto a device. Then they use that copy of the CBL DB as a template for their Prod App release.
To elaborate, if you include prebuilt version of your DB, then during initial startup, there would be something like an “empty sync” that happens with the SGW to get the CBL and SGW synced up on the state of things so subsequent changes can be replicated. During this sync, document bodies not get exchanged so it is very lightweight.
Not sure I get the context of this question. How you automate the process is unto you - for instance you can incorporate it into your CI/CD pipeline and bundle the generated prebuilt database into your app bundle
@priya.rajagopal Thought of giving greater context to make things even more clear and also because this is important for our product.
So, we store all the content in couchbase server and we want our CI/CD pipeline to build our mobile applications that has the pre-built couchbase lite database also packaged in it. Every time we release a new version of the app, we want to include the latest pre-built couchbase lite database.
The original answer provided above, says that someone should run the mobile app and execute a pull replication and then pull the couchbase lite database file out of that app which is then included in another build of the app. We ship a lot of apps and we are trying to automate the process of generating that initial couchbase lite pre-built database and include that in the mobile application build pipeline.
I hope this makes things more clear. Happy to provide any more information.
A related question : Is couchbase-lite pre-built database platform agnostic i.e., can we use a pre-built database built on android as is on iOS?
Yes. you will need a CBL based app that will pull the data and generate the database which you can then copy over to your mobile apps. This sole purpose of this app is to generate the database - naturally, this is different than the actual mobile app (that depends on the prebuilt database).
You have several options for the CBL based app . You can create a separate mobile app or a common option is to use our cblite tool . Others have built a simple Java based app that just pulls the data and generates the database.
Note that the prebuilt database must be generated by syncing data from the Sync Gateway/couchbase server that will be used in production. The channel filters that you use in replication must also match what will eventually be used in the app.
You can create a separate mobile app or a common option is to use our cblite tool .
So cblite cp is the command for performing the pull replication. Seems to be the simplest.
Others have built a simple Java based app that just pulls the data and generates the database.
This is good information. Creating a jvm based application to generate the pre-built database seems to be a feasible option.
Note that the prebuilt database must be generated by syncing data from the Sync Gateway/couchbase server that will be used in production. The channel filters that you use in replication must also match what will eventually be used in the app.
Ah. Thanks for adding this gotcha. Very useful.
Glad, things became more clear and you were able to help us out. Many thanks.