Skip to content

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 list

Let's call the Model as Model and the instance of that model as record.

Test if node is leaf

Check if the node is leaf (doesn't have children)

record.isLeaf(): bool

Test if node is root

Check if the node is root

record.isRoot(): bool

Check if node is equal

Check if the node is equal to the supplied node

record.isEqualTo(node): bool

Check if node is descendant

Check if the node is descendant of the supplied node

record.isDescendantOf(node): bool

Check if node is descendant or sibling

Check if the node is descendant or sibling to supplied node

record.isDescendantOfOrEqualTo(node): bool

Check if node is ancestor

Check if the node is ancestor of the supplied node

record.isAncestorOf(node): bool

Check if node is valid

Check if the node is valid. It checks the supplied node, or the source node otherwise.

record.isValidNode(node = null): bool

Clone this wiki locally