From 0691d234dd815a4ca0ae2484504f67f849d18b3b Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Sun, 16 Jan 2022 10:36:11 +0300 Subject: [PATCH] Update README.md --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c57067a..1e8b7c9 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,10 @@ Add `from db import CluttterDB` to the top of your project. Sets the key to the value in the JSON. if the `pathmagic` kwarg is given, it will spit it by the `+`'s and make dicts(or use existing ones) until it finishes, then it will set the value to the key in the last dict. -## `db.get(key: str, *, default=None)` +## `db.get(key: str, *, default=None, pathmagic="")` Returns the value of the key in the json, if the key isn't set in the json, it returns the default kwarg. + +if the `pathmagic` kwarg is given, it will spit it by the `+`'s and follow the path in it in the JSON data, will return the `default` kwarg if the path is empty or has a value that isnt a dict. ## `db.all()` Returns all the JSON data. ## `db.rem(key: str)` @@ -102,6 +104,23 @@ db = ClutterDB("db.json") data = db.get("test", default=123) +print(data) +``` +Output +``` +123 +``` +### Using with `pathmagic` kwarg +Code +```python +from db import ClutterDB + +db = ClutterDB("db.json") + +db.set("test", 123, pathmagic="a+b+c") + +data = db.get("test", pathmagic="a+b+c") + print(data) ``` Output