NoSQL.addOrUpdateKeys corrupting record and also clearing "Created On" and "Updated On" fields

0 votes

PARTIAL SELF-ANSWER SEE MY SECOND COMMENT

Trying to update JSON on a record is accepting the update, but removing all but one of the original fields. Also, importantly, the "Created On" and "Updated On" fields are being set to blank!

The one field that remains of the original data happens to be first alphabetically. It would appear to me that the record is failing internally to the NoSQL service during the update, and no error is being raised. SEE MY COMMENT BELOW

Original data after NoSQL.insertJSONDocument:

{
  "rank": 0,
  "alias": "scrub QY2EUR",
  "equipmentStored": {
    "numTimePacks": 0,
    "sessNumIceTeas": 0,
    "numIceTeas": 0,
    "sessNumTimePacks": 0
  },
  "aliasTerms": {
    "a9": "eur",
    "a0": "scrub qy2eur",
    "a1": "crub qy2eur",
    "a2": "rub qy2eur",
    "a3": "ub qy2eur",
    "a4": "b qy2eur",
    "a5": " qy2eur",
    "a6": "qy2eur",
    "a7": "y2eur",
    "a8": "2eur"
  },
  "login": "scrub QY2EUR",
  "battleHistory": {
    "summaries": []
  },
  "accountPK": "5bfd9b0de4b07b66c46b4cdf"
}

...now the corrupted record after NoSQL.addOrUpdateKeys:

{
  "test": "testData",
  "alias": "scrub QY2EUR"
}

Notice that only "alias" from the origianal record survived the addOrUpdateKeys.  The update code is not special, as below:

update = {test:"testData"};
nosqlSvc.addOrUpdateKeys(MASTER_DB_NAME, ACCOUNT_COLLECTION_NAME, accountDocId, update, ...

Also very importantly, the "Created On" and "Updated On" fields are blank after the call to NoSQL.addOrUpdateKeys.  See attached screenshot.

 

asked Nov 27, 2018 in Android by kustardking (12 points)
edited Nov 27, 2018 by kustardking
I just noticed in the App42Log.setDebug(true) output this:

[trace]  Setting Header value : selectKeys : {"alias":"1"}

...does this mean that I have to "unset" NoSQL.setSelectKeys?  How do I unset them after I've set them previously?
PARTIAL SELF-ANSWER

It was indeed the NoSQL.setSelectKeys that was limiting which fields would be *PRESERVED* during the update.  This seems like a bug to me, or else data-losing behavior should be documented.

So, playing around, I found that to reset the selection keys, you pass an empty array:

nosqlSvc.setSelectKeys([]);

Now, the reason I think the current behavior is actually bug is that "Created On" and "Updated On" are getting set to blank if setSelectKeys has any values and you then do an addOrUpdateKeys.

Can someone at AppWarp verify:

1) setSelectKeys([]) is the correct way to unset selection keys
2) if it is a bug that the "Created On" and "Updated On" fields are set to blank when doing an addOrUpdateKeys() when setSelectKeys() *has* 1 or more keys?

Please log in or register to answer this question.

Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...