-
Notifications
You must be signed in to change notification settings - Fork 10
Getting records
Anton Demushkin edited this page Jul 5, 2021
·
2 revisions
It's possible to fetch records using the Model:
const rootTag = await Tag.fetchRoot();
// or
const rootTags = await Tag.fetchRoots();
// or
const tags = await Tag.fetchTree();or using a record:
const someTag = await Tag.find(1234);
const siblingTag = await someTag.getPrevSibling();
// or
const childrenTags = await someTag.getChildren();
// or
const numberOfLeafs = someTag.getNumberDescendants();
// or another function from the listLet's call the Model as Model and the instance of that model as record.
Get root node for selected rootId.
async Model.fetchRoot(rootId = 1, options = {}): record|falseGet all tree nodes.
async Model.fetchTree(depth = 0, rootId = 1, options = {}): [record]|falseGet all root nodes.
async Model.fetchRoots(options = {}): [record]|falseGet previous sibling of the node.
async record.getPrevSibling(options = {}): record|falseGet next sibling of the node.
async record.getNextSibling(options = {}): record|falseGet all siblings of the node including current node or not.
async record.getSiblings(withCurrentNode = false, options = {}): [record]Get first child of the node.
async record.getFirstChild(options = {}): record|falseGet last child of the node.
async record.getLastChild(options = {}): record|falseGet all children of the node.
async record.getChildren(options = {}): [record]|falseGet all or limited by depth descendants for the node.
async record.getDescendants(depth = 0, options = {}): [record]|falseWarning! If you have parentId, then it uses only options.transaction and options.searchPath.
async record.getParent(options = {}): record|falseGet all or limited by depth ancestors for the node.
async record.getAncestors(depth = 0, options = {}): [record]|falseGet number of direct children nodes (only from one next level).
async record.getNumberChildren(options = {}): numberGet number of descendants (children and their children).
record.getNumberDescendants(): number