parent()

Returns the Obj representing the path-based parent of the Obj.

Copy
obj = Scrivito.Obj.getByPermalink("blog");
console.log(obj.parent().path());

Returns null if the Obj has no path or is the root Obj. It also returns null for an orphaned Obj, where the Obj itself has a path, but no other  Obj exists with a path matching the parent path.

Returns

Obj or null.

Examples

Find all orphans:

Copy
orphans = await Scrivito.load(() => {
  withPath = [...Scrivito.Obj.where('_path', 'startsWith', '/')];
  return withPath.filter(o => !o.parent());
});
console.log(orphans.map(o => o.path()));