Can anyone share sample Cordova github project which inserts JSON object as a document to Couchbase Lite


#1

I want to save a JSON object from Apache Cordova Javascript part to Couchbase Lite.
My JSON structure nested to ‘N’ level only outer attributes are common… Its a message structure which is POST ed to Server when app is online. I want to save the same JSON to Couchbase Lite without building the query with specific attributes.

Can someone share such sample project from Github / useful links?


#2

I has shared a sample cordova plugin project in response to your previous question related to queries. You should follow the same pattern as specified in the example for the other APIs .
Implement the document insertion logic natively in the plugin and expose a JS API that takes in the JSON. All of our native APIs are strongly typed so you will have to create MutableDocument type.You cannot pass in raw JSON string.
If you are looking for examples of how to do document creation natively , you can look at one of these other sample projects…there is a React Native module one as well.


#3

Thank you @priya.rajagopal for the reply.

I have implemented the CB Lite interaction in a cordova project. As you mentioned I was trying to pass raw JSON string to save as a document. With your reply I understood that it has to be typed structured data always and supporting model class (University in the sample project) should be present to typecast incoming JSON.