Closed xuanngo2001 closed 2 years ago
You need to have an up-to-date electronics object before getting its children. // Test getChildren()----------------------------------------await electronics.reload(); let children = await electronics.getChildren(); console.log(children);
Thx @fremail, it works with reload(). Can I know why it is not automatically updated? It is becoming increasingly cumbersome to call reload(). First, it is needed for addChild() and now getChildren().
In real life you don't need to insert and select nodes in the same code/function. Usually we have one method (e. g. API) for adding a node, another method for getting node(s). Calling reload() makes an additional query to DB. If your code is rather complex, it's better to control a number of DB queries. That's why I didn't put reload() inside each function
For the code below, I expect getChildren() to return Phones and TVs but it only returns Phones.
Output