0

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..

Scratch.
  • 343
  • 1
  • 6
  • 16

1 Answers1

1

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.

Roope Hakulinen
  • 7,326
  • 4
  • 43
  • 66
  • thnx for the answer, do you also now if a JSON is created when I call a .post? Because when I search my phone in root mode I can't find any JSON file? – Scratch. Dec 17 '14 at 21:40
  • 1
    I really aren't familiar with the Couchbase Lite, but I have had hard time finding out any files written by Cordova apps on my Android devices so that might explain you not seeing any files either, even though those would be persisted. Please see [this](http://stackoverflow.com/questions/27502853/where-are-files-saved-in-phonegap-app-stored-on-android) about that issue (see also [this](http://stackoverflow.com/a/27529487/1744702) about how to test for persisting). And yes, I think that POST should write those to DB and so on to file system. – Roope Hakulinen Dec 17 '14 at 21:48