-
Notifications
You must be signed in to change notification settings - Fork 10
Checking a record
Anton Demushkin edited this page Aug 4, 2019
·
1 revision
To check a record you need to get its instance before.
const someTag = await Tag.find(123);
const someOtherTag = await Tag.find(987);
if (someTag.isLeaf()) { /* do something */ }
// or
if (someTag.isValidNode()) { /* do something */ }
// or
if (someTag.isEqualTo(someOtherTag)) { /* do something */ }
// or
if (someTag.isDescendantOf(someOtherTag)) { /* do something */ }
// or another function from the listLet's call the Model as Model and the instance of that model as record.
Check if the node is leaf (doesn't have children)
record.isLeaf(): boolCheck if the node is root
record.isRoot(): boolCheck if the node is equal to the supplied node
record.isEqualTo(node): boolCheck if the node is descendant of the supplied node
record.isDescendantOf(node): boolCheck if the node is descendant or sibling to supplied node
record.isDescendantOfOrEqualTo(node): boolCheck if the node is ancestor of the supplied node
record.isAncestorOf(node): boolCheck if the node is valid. It checks the supplied node, or the source node otherwise.
record.isValidNode(node = null): bool