Node.Get
This commit is contained in:
parent
ddc31e4ca5
commit
c96da91077
3 changed files with 20 additions and 0 deletions
|
@ -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
|
v1.0.5, released 2025-03-16
|
||||||
* bugfixes
|
* bugfixes
|
||||||
- FixType - run recursevily into child nodes to get correct value
|
- FixType - run recursevily into child nodes to get correct value
|
||||||
|
|
|
@ -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
|
* 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
|
* 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
|
* 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
|
### helper commands
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,14 @@ func (node *Node) GetNodes() map[string]Node {
|
||||||
return node.Nodes
|
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) {
|
func InitDB(root string) (DB, error) {
|
||||||
db := DB{Root: root}
|
db := DB{Root: root}
|
||||||
err := db.Refresh()
|
err := db.Refresh()
|
||||||
|
|
Loading…
Add table
Reference in a new issue