HTML and CSS Reference
In-Depth Information
save : function(type, obj, successCallback, errorCallback) {
findAll : function(type, successCallback, errorCallback) {
delete : function(type, id, successCallback, errorCallback) {
findByProperty : function(type, propertyName, propertyValue, successCallback, errorCallback) {
findById : function (type, id, successCallback, errorCallback) {
There are a number of things going on here. Firstly, look at this line of code:
var request ='DB')
This is the request to open a database. The database may or may not exist before this call.
Our implementation is going to create a database named for the domain we are running
in, so if we are running using the hostname localhost, the database will be localhostDB,
whereas if we are running in the domain , the database will be called
www.testing.comDB .
The next point to note is that this returns a synchronous response. The response does not
imply the operation has completed however, it is necessary to add onsuccess and onerror
callbacks to the object returned. These will then be fired on success or failure: you can see
this occurring on the next few lines.
In the implementation above, the onsuccess callback also stores the result of the function
call in a private variable called database .
If you set a breakpoint and examine the properties of this object you will see the following:
Search WWH ::

Custom Search