Closed JopLaane closed 6 years ago
Hey,
Seems you found your problem.
Can you just post the solution in case anybody encounter it also ?
Db.delete() still doesn't work. I am repushing the same value at the momemt to overwrite the old one. If anyone can help with db.delete(), that would be awesome
Can I see your code in more details ?
I've added a new test to reproduce your issue, but without success. https://github.com/Belphemur/node-json-db/commit/505eaf2e3ccf7d77a46fd314e1da8971d1bb2e82
The data is deleted as expected.
Right I tried using db.getData(`/${role.name}`)
now, and this doesn't work either. for some reason it can't find the name in the db, even though it's clearly there.
Getting this error: [16:04:10] DataError: Can't find dataPath: /test. Stopped at test
It's documented.
When the data is not presents it throws a DataError. In other words, the delete did work.
You need to set saveOnPush
at true when creating the instance of JsonDB else the file don't get automatically updated.
Without saveOnPush
at true, you need to save the file manually with the method save
.
My file is saved automatically, also I am not using delete()
anymore, i am solely just trying to get the data from the database. Which returns the error.
Can you post the content of the json file containing the data ? and the path you're using ?
{
"brawlhalla:": "386474258659803136",
"payday2:": "386474384262430720",
"rainbow six siege:": "386474435000926221",
"golf with your friends:": "386474579851476992",
"pubg:": "386474624499580928",
"minecraft:": "386474651464892427",
"left4dead2:": "386474803407880192",
"cs:go:": "386475228156395530",
"gmod:": "386475260125511683",
"pokemon:": "386477372297183236",
"gta5:": "386477952558170122",
"rocket league:": "386522532431527939",
"human fall flat:": "386548983935270914",
"civ 5:": "386551922754060298",
"civ 6:": "386551940059889666",
"the division:": "386583992260100096",
"factorio:": "386658406888374292",
"diablo 3:": "387150515265601546",
"lol:": "387173972023836674",
"nsfw:": "387266630129811466",
"gw2:": "387980499290947586",
"warframe:": "388601035947638785",
"streamer:": "389393132099207169",
"deceit:": "389737810057363456",
"wow:": "389812232600551427",
"borderlands 2:": "390395132773400576",
"dutch:": "401068481598062592",
"ac:unity:": "425252805842829315",
"satellite reign:": "437584040191721472",
"wildlands:": "437651471551430677",
"sc2:": "444924060829483019",
"sonic adventure 2:": "444924563046793226",
"stardew valley:": "444924588330188800",
"doom:": "444924897223901186",
"prey:": "444924905109192724",
"smite:": "445281977466093578",
"warthunder:": "445617611808571403",
"duck game:": "453876642683682819",
"destiny 2:": "465269967961456650",
"trials fusion:": "467055933504356372",
"realm royale:": "468373163106107393",
"se4:": "486955203124527125",
"test:": "488722677205303327"
}```
Create the DB in the following way: `let subbableRolesDB = new jsondb("db/subbableRoles-db", true, true);`
Trying to get the data with the following: `subbableRolesDB.getData(`/${roleName}`);` where `role.name` = `test`
From the look of your JSON File I see a direct issue.
All the keys are /xxxx : with a colon (:).
You wanted test test
but test:
is the one in database.
In your example you're using test
without the colon, hence the issue you're encountering.
You should check your push
in the database to see where that colon is coming from.
Welp, i did not see that in the slightest, thanks for noticing that! Guess i overlooked it.
No problem, I didn't see it either until I created a specific test with your database :)
I'm closing this.
I am trying to delete an item from the database by doing the following: