typicode / lowdb

Simple and fast JSON database
MIT License
21.49k stars 923 forks source link

how to get data from json? #518

Closed maanp closed 2 years ago

maanp commented 2 years ago

Hey I am trying to get my data in db.json using db.get() but I can't do it? can you help me?

maanp commented 2 years ago

`const todos = db.get('todos').value() let index = 1; todos.forEach(todo => { const todoText =${index++}. ${todo.title}` console.log(todoText)

luukdv commented 2 years ago

@maanp I don't think db.get exists, maybe you're confusing it with the lodash chain example?

DarkestSeconds commented 2 years ago

@luukdv See this example: Discord Bot . Use db.get(message.guild.id) to store an id

luukdv commented 2 years ago

@DarkestSeconds Those examples use an older version of lowdb. See https://github.com/typicode/lowdb/releases/tag/v2.0.0 for migration info.

typicode commented 2 years ago

Thank you @luukdv