We're looking into this odd behavior in further detail as it seems like findOne() returns a JSON doc that doesn't like to be changed.
In the meantime one workaround is to Stringify the doc returned then create a new JSON doc by parsing this string.
var doc = col.findOne( {"playerId":playerId} );
var updatedDoc = JSON.parse(JSON.stringify(doc))
This should allow you to alter the updatedDoc the way you want.
If you have any other questions let me know,
Pádraig
Customer Support
said
almost 7 years ago
Update:
As I suspected It’s a bug similar to one we fixed previously (https://support.gamesparks.net/helpdesk/tickets/1775). Basically if you use a key that is an integer value (even if it’s passed in as a string) the engine running the Cloud Code does some weird stuff with it.
This is being fixed next release. In the meantime, please use the workaround.
Lee Ki Jeong
Hi,
I've made a collection named ‘UserInfo’ which contains following:
In cloud code,
when I trace above code in debug mode, doc.inven.chars[ “1” ] is undefined.
I don’t understand why it can’t be assigned.
one more thing,
Please help me...
Hi Lee,
We're looking into this odd behavior in further detail as it seems like findOne() returns a JSON doc that doesn't like to be changed.
In the meantime one workaround is to Stringify the doc returned then create a new JSON doc by parsing this string.
This should allow you to alter the updatedDoc the way you want.
If you have any other questions let me know,
Pádraig
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Thanks Lee,
We're looking into this.
Oisin
Customer Support
Hi Lee,
We're looking into this odd behavior in further detail as it seems like findOne() returns a JSON doc that doesn't like to be changed.
In the meantime one workaround is to Stringify the doc returned then create a new JSON doc by parsing this string.
This should allow you to alter the updatedDoc the way you want.
If you have any other questions let me know,
Pádraig
Customer Support
Update:
As I suspected It’s a bug similar to one we fixed previously (https://support.gamesparks.net/helpdesk/tickets/1775).
Basically if you use a key that is an integer value (even if it’s passed in as a string) the engine running the Cloud Code does some weird stuff with it.
This is being fixed next release. In the meantime, please use the workaround.
Thanks,
Pádraig
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics