Update Storage

I already write a data as Kills and Deaths values.
But also I want to write the same kills and death value?? Again After another match…
How did I update?

Hey @Looper, welcome to our forum.

If I understand your question correctly, you’re writing a storage object with kills and deaths fields which you want to update after every match based on its outcome.

The correct solution would be, after the match ends, to check if a storage object already exists by reading from storage, if not, just write it with the current results. If it does exist however, you should use the current values of the read object to calculate their sums based on the outcome of the match and store the updated storage object to overwrite the previous one.
Make sure you use the returned version you get from nkStorageRead when you write, to ensure you’re not overwriting the storage object with stale data.

You could also use custom sql to update these fields in the DB directly with a single query, but we discourage this approach unless you’re sure you need the performance optimization.

I’d kindly ask you to refrain from tagging people unless you’re replying to them directly.

Hope this helps.

1 Like

How to store data using server side code?

You can see a few examples on how to write to storage with the runtime here: Function Reference - Heroic Labs Documentation

Thanks
@sesposito Got it

But ,
How to update the data using sql ?