Coder Social home page Coder Social logo

Comments (5)

Belphemur avatar Belphemur commented on August 18, 2024

It really depends exactly what you want to do. If you want to set up a template like basic HP, level for monster etc ... or you want to use it to save the state of a player.

Keep in mind, this "database library" is really not made for doing a lot of change in the same time, I created it to simplify the use of json files.

What I would do is create a Player Object with all those different properties then save in the database using push at the point /players/[PLAYER_NAME] that object. Where [PLAYER_NAME] would be the unique name of the player (username).

Like this you would be able later to retrieve it directly (getData(/players/[PLAYER_NAME])) and do what you must with it.

from node-json-db.

LordYusei avatar LordYusei commented on August 18, 2024

I see. So I would do something like db.push('/players/player.name') and then define each area, right?

from node-json-db.

Belphemur avatar Belphemur commented on August 18, 2024

either that if you're setting the whole object but you can also set each part separatly:

db.push('/players/player.name/hp', 10)
db.push('/players/player.name/exp', 100)

etc...

when you'll do a db:getData('/players/player.name') you'll get an object containing hp and exp.

There are a lot of examples in the test scripts

from node-json-db.

LordYusei avatar LordYusei commented on August 18, 2024

Oh I see. Thanks so much for the help. :)

from node-json-db.

Belphemur avatar Belphemur commented on August 18, 2024

I close this for now. Don't hesitate to reopen it if you have further questions.

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.