diff --git a/CHANGELOG b/CHANGELOG index a72b827..9418ad5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v1.0.6, released 2025-03-16 + * features + - Node.Get - get object property value + v1.0.5, released 2025-03-16 * bugfixes - FixType - run recursevily into child nodes to get correct value diff --git a/README.md b/README.md index c2fd37b..e53ac53 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,14 @@ Commands can be split into value layer when you know the structure and node laye * GetNode - to get node. It can be object, list or value object. Returns false if not exist * CreatNode - create list (director) to add many same objects (structure should be controlled by user) or single object. Parent Node should exist * AddObject - add object to given list. Should assign abcex id +* Length - get length of list +* GetRandomNode - get random object from list + +### Node as Object commands + +* Node.Get - get object property value +* Node.GetNodes - get object properties +* Node.FixType - checks and sets object/list type ### helper commands diff --git a/zordfsdb.go b/zordfsdb.go index 5b56f53..2c88cd1 100644 --- a/zordfsdb.go +++ b/zordfsdb.go @@ -36,6 +36,14 @@ func (node *Node) GetNodes() map[string]Node { return node.Nodes } +func (node *Node) Get(key string) (string, error) { + if _, ok := node.Nodes[key]; ok { + return node.Nodes[key].Value, nil + } + + return "", fmt.Errorf("Key not found") +} + func InitDB(root string) (DB, error) { db := DB{Root: root} err := db.Refresh()