Trying Couchbase Lite for this first time. I have this fairly large JSON file that contains all my data. Is it possible to convert it to a couchbase file and bundle along with my Android app? I intend to perform only reads and search on the db.
Yes. If you look at the Todo sample app, you can see an example of bundling a prebuilt database. You’d need to write a simple app to ingest the data and create the database, but that’s very simple.
Hello Hamza, I am in the same situation and was wondering if you were able to create the local Couchbase database with your JSON document. If so, I would love to know how you handled that. I’ve been hunting around the documentation and blogs and could only find general information on how to do this. Just to be clear, I understand how to create an empty database and how to bundle it with an application. What I don’t see out there is any example of how to populate the empty database with JSON data.
Can you describe more about your use? How often do you expect to need to create the database? What are the characteristics of the data (number of separate documents, size)?
Off the top of my head I can think of a few approaches to do this. Perhaps the easiest, most general version that comes to mind is to write a Java desktop application that reads in your JSON then replicates it through Sync Gateway to a mobile device. You could then extract the database. This would be using the Couchbase Lite Java SDK and the appropriate mobile SDK.
Thanks for responding. So basically I have a dataset of about 400 documents with each document having perhaps a dozen elements to it. All the elements are static and would rarely be modified, although I would be adding documents every few months or so. Think of a product list with data attached to each product. I then want to load up the product list and have basic elements (name and category) show up in a pickerview populated from the prebuild Couchbase lite.
I’m a little surprised that I haven’t found a tool already out there that does the loading as it seems like it would be a very useful thing to have.
My focus is on the iOS application and its usability and hoping to not get caught up in the data loading process.
Yes, it would be good to have such a tool. I may see if I can put something together.
So one relatively easy approach (which you could set up all on one machine) would be to write a shell script that pushes your docs to Sync Gateway using the REST API (maybe with curl or Postman). Then have a simple app on mobile that replicates the data to create the db. Extract that and bundle it. (This avoids writing a desktop Java tool.)
Let me know if that seems viable. There are probably other approaches to consider if it isn’t.