Coder Social home page Coder Social logo

Comments (11)

Belphemur avatar Belphemur commented on July 19, 2024

Hey,

Seems you found your problem.

Can you just post the solution in case anybody encounter it also ?

from node-json-db.

JopLaane avatar JopLaane commented on July 19, 2024

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

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

Can I see your code in more details ?

I've added a new test to reproduce your issue, but without success.
505eaf2

The data is deleted as expected.

from node-json-db.

JopLaane avatar JopLaane commented on July 19, 2024

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

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

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.

from node-json-db.

JopLaane avatar JopLaane commented on July 19, 2024

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.

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

Can you post the content of the json file containing the data ? and the path you're using ?

from node-json-db.

JopLaane avatar JopLaane commented on July 19, 2024
{
    "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 node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

From the look of your JSON File I see a direct issue.

All the keys are /xxxx : with a colon (:).

Example:

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.

from node-json-db.

JopLaane avatar JopLaane commented on July 19, 2024

Welp, i did not see that in the slightest, thanks for noticing that! Guess i overlooked it.

from node-json-db.

Belphemur avatar Belphemur commented on July 19, 2024

No problem, I didn't see it either until I created a specific test with your database :)

I'm closing this.

from node-json-db.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.