Backendless Version (REST API ver?)
Client SDK (Python (REST))
Application ID : FF55A111-06AF-7EB1-FFDE-B5B62760CA00
Expected Behavior ???
Actual Behavior
- call my python write_database_object() function
- JSON response of write_database_object response = {‘code’: 1364, ‘message’: “Field ‘itemID’ doesn’t have a default value”, ‘errorData’: {}}
___operation=JSON_SET
MY QUESTION IS:
How should I be structuring an users Item Inventory and updating the amounts and itemIDs??? (as u can see i was looking at JSON_SET but i failed due to resolve the error code above.)
(basically i need one call to update a whole obj, but most times only one entry inside that)
Also, I was thinking transactions might be an idea for item updates…
but then i’m also thinking of frequency of updates…
Reproducible Test Case: (PYTHON)
backendless = PyBackendless.Backendless(APP_ID, REST_KEY)
#ITEMS = ItemsClass_BOUNCY_OC.ITEMS()#ITEMS IDs as VARIABLES
#THE FOLLOWING USER CAN BE USED WITHOUT hmac
data = {}
data["login"] = "NOhmacPW"
data["password"] = "12345"
response = backendless.login_user(data)
#backendless.initialize_user(response) #inside login_user
print(backendless.objectId)
tableName = "ItemInventory"
invJSONupdata = {
"JSONinv":{
"___operation":"JSON_SET",
"args":{
"$.slot0.itemID":0,
"$.slot0.amt":1000000,
"$.slot1.itemID":1,
"$.slot1.amt":111,
"$.slot2.itemID":2,
"$.slot2.amt":11,
"$.slot3.itemID":3,
"$.slot3.amt":10,
"$.slot4.itemID":4,
"$.slot4.amt":100
}
}
}
where = "ownerId = '"+str(backendless.objectId)+"'" #WHERE: owner == user && itemID == itemID
response_containing_one_or_more = backendless.read_database_object(tableName,"JSONinv",where) #Returns
print("response_containing_one_or_more=",response_containing_one_or_more)
objectId = ""
if isinstance(response_containing_one_or_more, dict):
already_have = True
objectId = response_containing_one_or_more["objectId"]
response = backendless.update_database_object(tableName,invJSONupdata,objectId)
print("___operation=JSON_SET")
print(response)
RESPONDS WITH:
{‘code’: 1364, ‘message’: “Field ‘itemID’ doesn’t have a default value”, ‘errorData’: {}}
NEED HELP PLEASE…
Mainly I need know how I should be structuring a users Item Inventory and updating their Item amounts and itemIDs ???
Also… I’m not rich, so if there’s a cost effective way to do it, that’d be great…
EDIT:
really need it to be able to handle thousands of concurrent users too…
Thanks, Jessie.