Update method overwrites variables it's not supposed to overwrite i.e. not specified in update object [this issue is holding a product back from progressing to users] #47
Then some lines later I pass - explicitly (or some milliseconds later another function fires due to an event that occurred and passes) another one like:
Then, when I check the console logs (which are AWESOME), I find that the first update call did successfully change the age - as intended, but the second call changed the gender and also seems to have overwritten the previous update of the age and restored it back to what it was when it began execution. The console logs when update statements of the structure:
are used, provide a full state echo of the object post transaction and was how I was able to see clearly that the the first update did happen, but it was overwritten by the second.
This is a simplification of the real situation though: in the real context, a lot more get, update, and 'get, then update' calls are involved in one runtime.
I'm wondering why this is happening, and how I can quickly correct this, so I always get the desired outcome, dependably?
I've tried a lot of stuff. I moved from updates using a variable in the object as the key to updating using the key set for the objects: NOTHING; I then tried using different handles for some of the transactions: different instances of the localbase object: NOTHING. Then I tried using different parameter names in the .then((para_1)=>{ }) blocks involved in a lot of the update-then do stuff operations (to address the possibility that their having the same name could be causing them to be saved in the same namespace in memory - leading to conflicts and overwrites at that level): NOTHING.
I'm a hard core SQL person: so I'm really just hopping into the no-SQL terrain. I like the flexibility of noSQL but this non-reliability in getting updates done which leads to the fear that stuff can break and the fear of adding new functionalities to an already shaky system is making me wonder if this is a noSQL issue, or if the challenge is with the way I wrote the code? A lot of times the update calls are fired by different methods activated by different, the same or connected events: so I even had to do some settimeout sequencing to make sure they don't clash and execute in the right order.
Though there are a couple of other tasks I need to work through to get the product out, this is the only technical issue which impacts on the dependability of the product to deliver on its core promise: IMAGINE PLAYING A GAME, WINNING, AND IT DOES NOT UPDATE THAT YOU WON.
Hey everyone. Localbase is AWESOME.
I'm having a little ish though. To update an object (in a collection named e.g. hey_yo) that's like:
//object state before transactions { age: 14, gender: "male", height: "2.4m", location: "USA", id: "human" }
I pass an update call like:
db.collection('hey_yo').doc({ id: "human" }).update({ age: 16 });
Then some lines later I pass - explicitly (or some milliseconds later another function fires due to an event that occurred and passes) another one like:
db.collection('hey_yo').doc({ id: "human" }).update({ gender: female});
And ultimately, I get:
{ age: 14, //not updated gender: "female", // updated height: "2.4m", location: "USA", id: "human" }
Then, when I check the console logs (which are AWESOME), I find that the first update call did successfully change the age - as intended, but the second call changed the gender and also seems to have overwritten the previous update of the age and restored it back to what it was when it began execution. The console logs when update statements of the structure:
db.collection('hey_yo').doc("object_key_name").update({ gender: female});
are used, provide a full state echo of the object post transaction and was how I was able to see clearly that the the first update did happen, but it was overwritten by the second.
This is a simplification of the real situation though: in the real context, a lot more get, update, and 'get, then update' calls are involved in one runtime.
I'm wondering why this is happening, and how I can quickly correct this, so I always get the desired outcome, dependably?
I've tried a lot of stuff. I moved from updates using a variable in the object as the key to updating using the key set for the objects: NOTHING; I then tried using different handles for some of the transactions: different instances of the localbase object: NOTHING. Then I tried using different parameter names in the .then((para_1)=>{ }) blocks involved in a lot of the update-then do stuff operations (to address the possibility that their having the same name could be causing them to be saved in the same namespace in memory - leading to conflicts and overwrites at that level): NOTHING.
I'm a hard core SQL person: so I'm really just hopping into the no-SQL terrain. I like the flexibility of noSQL but this non-reliability in getting updates done which leads to the fear that stuff can break and the fear of adding new functionalities to an already shaky system is making me wonder if this is a noSQL issue, or if the challenge is with the way I wrote the code? A lot of times the update calls are fired by different methods activated by different, the same or connected events: so I even had to do some settimeout sequencing to make sure they don't clash and execute in the right order.
Though there are a couple of other tasks I need to work through to get the product out, this is the only technical issue which impacts on the dependability of the product to deliver on its core promise: IMAGINE PLAYING A GAME, WINNING, AND IT DOES NOT UPDATE THAT YOU WON.
SOMEONE NEEDS TO F**KING SAVE ME, FAST!