Database is caching(?) values and resetting them even if deleted?
I've got some code to make a text-adventure game. I'm trying to use the Database for progress flags.
this section is moving some crates to find something.
if((args.move === "crates")) {
// do stuff
if (#db.f({_id:PlayerPATH}, {_id:0, cratemove:1}).distinct("cratemove") == "cratemove"){
return "`B***The crates are already up against the walls.***`"
}else{
#db.us({_id:PlayerPATH}, { $set:{cratemove:"cratemove"} })
return "`B***You move the crates against the side walls, creating a path through the middle and exposing the ``Vfurnace``B .***`"
}
}
The variable was originally called 'movedcrates'. I changed it as it was exhibiting odd behaviour and I wanted to test fresh.
I have a dbcheck script.
if(!args) {
let data = #db.f().count()
return data
}
>>dbcheck {user:"sud", path:"path"}
{
_id: "sudpath",
movedcrates: "movedcrates",
cratemove: "cratemove"
}
>>sud.dbcheck
3
shows that I have 3 items.
I ran a delete
if(args.delete === true) {
return #db.r({})
}
>>dbcheck {delete:true}
{
n: 3,
opTime: {
ts: "Undefined Conversion",
t: 3
},
electionId: "Undefined Conversion",
ok: 1,
operationTime: "Undefined Conversion",
"$clusterTime": {
clusterTime: "Undefined Conversion",
signature: {
hash: "Undefined Conversion",
keyId: "Undefined Conversion"
}
}
}
>>sud.dbcheck
0
tried to delete it so we're down to zero items.
Then I went through the process to move the crates again, and checked my DB flags.
>>sud.pathways {move:"crates"}
***You move the crates against the side walls, creating a path through the middle and exposing the furnace
.***
>>dbcheck {user:"sud", path:"path"}
{
_id: "sudpath",
movedcrates: "movedcrates",
cratemove: "cratemove"
}
and both the old flag and the new flag were found.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is super curious!
Maybe someone on the discord can help out to isolate the issue with you:
https://discord.com/channels/229545531104296960/229548701138419712
(if that direct link to the programming_help channel doesn't work, here's an invite link to the server: https://discord.gg/CCA8av7x)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -