Search code examples
cordovacouchbase-lite

Instruction on how to use POST PUT GET DELETE, Couchbase Lite on Cordova


I am trying to implement Couchbase Lite on my Cordova Project and need some help.

How do I Test if the values submitted are correct, and how should I read the values?

I need some proper documentation on how to use the

config.db.post
config.db.get
config.db.delete
config.db.put

but sadly I can't find any.

For example when I do the Following, I get 2 alerts in the following exact order:

Alerts:

null 

object, object // how can I read this?

For Code:

config.db.post(composition, function(err, ok) {
    alert(err);
    alert(ok);
}

does this mean the JSON File was created? I can't seem to find any JSON Files on my Phone..


Solution

  • Based on the alert values, there is no error (first alerted value is null) & the returned data is an object. You can alert "through" the object like this

    config.db.post(composition, function(err, ok) {
        for (var i in ok) {
            //if (ok.hasOwnProperty(i)) {
                alert(ok[i]);
            //}
        }
    }
    

    Also if you take out the comments, you can see only the attributes that are actually set to the result object instead of seeing all of JavaScript functions that exist for every object in JS. Also, if you can use debugger, it is much easier to see what the ok variable contains. GapDebug is perfect choice for debugging PhoneGap applications, but may require some effort to get up and running.