Deleting Data
await gom.delete(Person, uuid); // returns how many: 1 or 0await gom.delete(Issue, uuid, { where: (q) => q.state.eq('closed') }); // only if it meets the conditionawait gom.deleteAll(Issue, (q) => ({ where: q.state.eq('closed') })); // what a load with the filter findsawait gom.deleteAll(RaisedAndAssignedIssue, (q) => ({ where: q.assignedTo.name.eq('Former Employee') }));await gom.deleteAll(Issue, 'n.locked = true'); // a predicate of your own, over nA delete removes the root and its relationships. The nodes they led to stay, unless the delete cascades. Deleting a view by id can also delete the nodes it reaches:
await gom.delete(SessionView, sessionId); // NONE: the root onlyawait gom.delete(SessionView, sessionId, { cascade: CascadeType.DELETE_ORPHAN }); // and each node nothing outside it needsawait gom.delete(SessionView, sessionId, { cascade: CascadeType.DELETE_ALL }); // and every node in the viewThe cascade follows the relationships a save of the view writes, through nested views; a node outside the view is never
deleted. So it leaves what a read-only field loads (a @ReadOnly() field, a @GraphPath, and a list of fragments read
over several hops): other code writes those nodes. A view that contains itself is not read-only, so each of its levels
is deleted. DELETE_ALL deletes nodes others may still point at, so use it for nodes the root owns. DELETE_ORPHAN
keeps a node in the view that a node outside it still refers to, at any level, together with everything the view holds
below it: a bookmarked message keeps its attachments, and a pinned sub-session keeps its messages and its own
sub-sessions. The rest of the view is deleted, including the session that held a kept message. DELETE_ORPHAN isn’t
available on Memgraph.
A view that contains itself (parts: SessionTree[], with a maxDepth) deletes what a load of it reads: the nodes at
every level, and what each level holds through the view’s other relationships a save writes. A cascade never stops
short: if the relationship reaches below its maxDepth, the delete throws a DrivineError before anything is written,
saying how deep the view reads. Raise the maxDepth to cover the deepest level.

