2
votes

Is there any API to remove a collection without initialize the collection?

Here is my scenario. There is a KeyCollection that store credential from server to initialize the other collection. User has to key in credential to unlock the KeyCollection. It is use to cater forget password scenario that do not wipe off(destroy) the whole database which is request by our client. User forgot the password of a collection, so the system will only remove the Keycollection and init with new user credential and get the credential from server again.

I unable to remove a collection without initialize it, and below is the code that remove the collection from device. Is there any alternative to cater the scenario or remove the collection in order for me to .init again?

.Get Use get to create an accessor to the collection. You must call init before you call get otherwise the result of get is undefined (From IBM Website)

    var options = {};

    WL.JSONStore.get(collectionName).removeCollection().then(function (removeCollectionReturnCode) {
    }).fail(function (errorObject) {
    });
2
@Idan Adar , Do you have any thoughts for this question? - Terry Chew

2 Answers

0
votes

There is the choice of the use of the destroy method, but this removes more than the just the collection. It could be removing more than you would like by the scenario described.

http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/html/refjavascript-client/html/WL.JSONStore.html%23destroy?lang=en

Completely wipes data for all users, destroys the internal storage, and clears security artifacts.

More details here: http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.dev.doc/devref/c_jsonstore_api_concepts.html?lang=en

Destroy Completely wipes data for all users, destroys the internal storage, and clears security artifacts. The destroy function removes the following data:

All documents. All collections. All stores. For more information, see JSONStore multiple user support. All JSONStore metadata and security artifacts. For more information, see JSONStore security.

An example of use:

WL.JSONStore.destroy()

.then(function () {
  // Handle success.
})

.fail(function (errorObject) {
  // Handle failure.
});

I hope this info helps,

0
votes

You will need to have the password before you can do any operation with the database. You could just hash the password in a separate database and if the person has forgotten it just change the password with a temporary password or a new password of the user's choosing.