C5050-408 Free Dumps Study Materials
Question 2: An application developer is using JSONStore in a mobile application to store purchase orders.
The application allows sellers to modify the status of an order. The JSONStore collection for the
orders is defined in a global variable as follows: var ordCollection = { orders: {
searchFields: {ord_number: 'integer', status: 'string' }
}
};
Which of the following JavaScript functions can the application developer use to change the status of
an order in the local JSONStore?
A. var updateOrder = function(orderDoc, newStatus){ orderDoc.json.status = newStatus;
WL.JSONStore.update(ordCollection, orderDoc) .then(function
(numberOfDocumentsUpdated) { // Handle success. })fail(function (errorObject) { // Handle
failure.
});
};
B. var updateOrder = function(orderDoc, newStatus){ orderDoc.json.status = newStatus;
var ordColInstance = WL.JSONStore.get(ordCollection);
var numberOfDocumentsUpdated = ordColInsnance.update(orderDoc); if(
numberOfDocumentsUpdated >= 0 ){
// Handle Success
} else {
// Handle Failure
}
};
C. var updateOrder = function(orderDoc, newStatus){ orderDoc.json.status = newStatus;
WL.JSONStore.get('orders').replace(orderDoc) .then(function
(numberOfDocumentsReplaced) { // Handle success. })fail(function (errorObject) { // Handle
failure.
});
};
D. var updateOrder = function(orderDoc, newStatus){ orderDoc.json.status = newStatus;
var ordColInstance = WL.JSONStore.get('orders');
var numberOfDocumentsReplaced = ordColInsnance.replace(orderDoc); if(
numberOfDocumentsReplaced >= 0 ){
// Handle Success
} else {
// Handle Failure
}
};
Correct Answer: B
Explanation:
WL.JSONStore.get(collectionName)
Provides an accessor to the collection if the collection exists, otherwise it returns
undefined.
Must reference OrdCOllection in the Get statement.
References:
https://www.ibm.com/support/knowledgecenter/SSHS8R_6.3.0/com.ibm.worklight.apiref.do
c/html/refjavascriptclient/html/WL.JSONStore.html