Skip to content

Creating a record

Anton Demushkin edited this page Aug 4, 2019 · 2 revisions

To create a new record you need to create an instance of the Model and then use one of the listed functions.

let newTag = new Tag();
newTag.label = 'New root tag';

newTag = await Tag.createRoot(newTag);
// or
await someExistingTag.addChild(newTag);
// or
await newTag.insertAsParentOf(someExistingTag);
// or another function from the list

Warning! You can use these functions only with records w/o its own place in the tree (w/o left and right values in other words). If you need to move the existing records, see Moving a record page.

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

Create root node

Create a root node from existing or new record.

async Model.createRoot(record, options = {}): record

Insert as parent

Insert the node (from which you call the function) as parent of destination node.

async record.insertAsParentOf(destNode, options = {})

Insert as previous sibling

Insert the node (from which you call the function) as previous sibling of destination node.

async record.insertAsPrevSiblingOf(destNode, options = {})

Insert as next sibling

Insert the node (from which you call the function) as next sibling of destination node.

async record.insertAsNextSiblingOf(destNode, options = {})

Insert as first child

Insert the node (from which you call the function) as first child of destination node.

async record.insertAsFirstChildOf(destNode, options = {})

Insert as last child

Insert the node (from which you call the function) as last child of destination node.

async record.insertAsLastChildOf(destNode, options = {})

Add child

Add the node as last child of the supplied node (new parent)

async record.addChild(parentNode, options = {})

Clone this wiki locally