Skip to content

Commit

Permalink
Update index.ts to fix set not updating the value properly
Browse files Browse the repository at this point in the history
The set will now properly update the key in the database by removing the old value from the key if the key already exists in the database.
  • Loading branch information
PAPISOP authored Aug 5, 2023
1 parent 01b2ec9 commit 9f867f5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/jaylydb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ class JaylyDB implements Map<string, string | number | boolean> {
if (encoded.length > 32767) throw new RangeError("JaylyDB::set only accepts a string value less than 32767 characters.");

// push change to disk
const participant = this.localState.get(key);
if (participant) this.objective.removeParticipant(participant.identity);
this.objective.setScore(encoded, 0);
const data = {
encoded_value: encoded,
Expand Down

0 comments on commit 9f867f5

Please sign in to comment.