Darren-project / obsidian-kv

Adds a key-value store to Obsidian. Use it to store and retrieve key-value pairs in your vault.
Apache License 2.0
4 stars 1 forks source link

[HELP] Creating a more complex Database #5

Open FelipeRearden opened 1 month ago

FelipeRearden commented 1 month ago

Hello @mickeydarrenlau !!!!

I am trying to create a database and using templater to get data from the database and I need some help.

Since I am a newbie, I am struggling to create the database in the right way :(

Idea

Instead of have a single structure, I would like to have more than one databases inside kv in a way that I can modify each subset of data independently (as if where two KV plugins) .

Example

this is the database that I am creating:

{
  "lorem": {
    "key1": "value1",
    "key2": "value2"
  },
  "ipsum": {
    "key3": "value3",
    "key4": "value4"
  }
}

As you can see, I have two dbs lorem and ipsum

I am running this simple templater script to validade my database and see if I can access only the content from the lorem db:

<%*
const ks_lorem = await kv.lorem.keys();
const val_lorem = await kv.lorem.values();
new Notice(ks_lorem, 3000)
new Notice(val_lorem, 3000)
%>

HELP Request

Would you mind helping me to fix my KV database. I know that I am doing something wrong in the structure. BUt after 4 hours searching and testing, I really don’t know what I am doing wrong.

I hope you could help me 🙏


I wish you a fantastic day ☀️

mickeydarrenlau commented 1 month ago

kv.get("Ipsum")["key3"]

On Thu, 26 Sept 2024, 4:52 am FelipeRearden, @.***> wrote:

Hello @mickeydarrenlau https://github.com/mickeydarrenlau !!!!

I am trying to create a database and using templater to get data from the database and I need some help.

Since I am a newbie, I am struggling to create the database in the right way :( Idea

Instead of have a single structure, I would like to have more than one databases inside kv in a way that I can modify each subset of data independently (as if where two KV plugins) . Example

this is the database that I am creating:

{ "lorem": { "key1": "value1", "key2": "value2" }, "ipsum": { "key3": "value3", "key4": "value4" } }

As you can see, I have two dbs lorem and ipsum

I am running this simple templater script to validade my database and see if I can access only the content from the lorem db:

<%* const ks_lorem = await kv.lorem.keys(); const val_ipsum = await kv.lorem.values(); new Notice(ks_lorem, 3000) new Notice(val_lorem, 3000) %>

HELP Request

Would you mind helping me to fix my KV database. I know that I am doing something wrong in the structure. BUt after 4 hours searching and testing, I really don’t know what I am doing wrong.

I hope you could help me 🙏

I wish you a fantastic day ☀️

— Reply to this email directly, view it on GitHub https://github.com/Darren-project/obsidian-kv/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO6YPGE2J7IADQM5XMRLQILZYMO77AVCNFSM6AAAAABO3MBJDSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2DQOJXG44TCOA . You are receiving this because you were mentioned.Message ID: @.***>

FelipeRearden commented 1 month ago

Thank you very much for the reply @mickeydarrenlau !!!

kv.get("Ipsum")["key3"]

It worked !!!!

One more question: How do I get all keys from ipsum ?

I tried kv.get("ipsum").keys(); but it did not work

For this templater script, I need to create two arrays:

Can you help me one more time? 🙏