hi,
I want to store 5 set of stats for each user. Basicly they give me some values and a number and it gets stored online
Here is the cloudcode:
var playerID = Spark.getPlayer().getPlayerId(); var hp = Spark.getData().hp; var dmg = Spark.getData().dmg; var cdr = Spark.getData().cdr; var setbonus = Spark.getData().setbonus; var setID = Spark.getData().nr; var ms = Spark.getData().ms; var wholeSetBonus = { "nr": setID, "hp": hp, "dmg": dmg, "cdr": cdr, "ms": ms, "setbonus": setbonus } var dataCol = Spark.runtimeCollection("sets"); dataCol.update({ "_id": playerID, "nr": setID }, { "$set": wholeSetBonus }, true, false );
And here is the error:
"message": "Write failed with error code 11000 and error message 'E11000 duplicate key error index: 304283-game-preview.script.sets.$_id_ dup key: { : \"5835639ab5973404b3f4b1ca\" }' (event/setStarsets.js#31)"
When _id & nr NOT FOUND in DB "wholeSetbonus" is stored correctly.
When _id & nr FOUND in the DB "wholeSetbonus" is updated correctly.
When _id is FOUND, but nr is NOT FOUND, i get the error message.
I thought that update with $set creates a new db entry when its not found.
Hi Kelvin
GameSparks uses MongoDB for our Database's.
The problem is the _id is a unique key given by MongoDB for each document.
You cannot set the _id it is auto generated by MongoDB
You could add a key called something else like player_id to store the playerId.
Regards
Katie
Kelvin Petry
hi,
I want to store 5 set of stats for each user. Basicly they give me some values and a number and it gets stored online
Here is the cloudcode:
And here is the error:
When _id & nr NOT FOUND in DB "wholeSetbonus" is stored correctly.
When _id & nr FOUND in the DB "wholeSetbonus" is updated correctly.
When _id is FOUND, but nr is NOT FOUND, i get the error message.
I thought that update with $set creates a new db entry when its not found.
Hi Kelvin
GameSparks uses MongoDB for our Database's.
The problem is the _id is a unique key given by MongoDB for each document.
You cannot set the _id it is auto generated by MongoDB
You could add a key called something else like player_id to store the playerId.
Regards
Katie
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Kelvin
GameSparks uses MongoDB for our Database's.
The problem is the _id is a unique key given by MongoDB for each document.
You cannot set the _id it is auto generated by MongoDB
You could add a key called something else like player_id to store the playerId.
Regards
Katie
1 person likes this
Kelvin Petry
Thanks for your answer anyway, i hope others see this, as this "error" happened to others aswell.
-
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