-
Notifications
You must be signed in to change notification settings - Fork 10
Moving a record
Anton Demushkin edited this page Aug 4, 2019
·
2 revisions
To move a record you need to get its instance before.
const tagToMove = await Tag.find(1234);
const destinationTag = await Tag.find(321);
await tagToMove.moveAsPrevSiblingOf(destinationTag);
// or
await tagToMove.moveAsLastChildOf(destinationTag);
// or
await tagToMove.makeRoot();
// or another function from the listWarning! You can move record only if it's a valid node == it has its own place in the tree == it has left and right values. If it doesn't, please see Creating a record page.
Let's call the Model as Model and the instance of that model as record.
Move the node (from which you call the function) as previous sibling of destination node.
async record.moveAsPrevSiblingOf(destNode, options = {})Move the node (from which you call the function) as next sibling of destination node.
async record.moveAsNextSiblingOf(destNode, options = {})Move the node (from which you call the function) as first child of destination node.
async record.moveAsFirstChildOf(destNode, options = {})Move the node (from which you call the function) as last child of destination node.
async record.moveAsLastChildOf(destNode, options = {})Make this node a root node and move all its descendants to the new tree. Only for multiple-root trees.
async record.makeRoot(options = {})