schema.cardinality
cardinality(key: string, scope: "nodes" | "edges"): numberTotal distinct values for a property key (full scan).
Unlike values() this always scans the entire graph to give an exact count.
key | string | The property key to count distinct values for. |
scope | "nodes" | "edges" | "nodes" (default) or "edges". |
Returns: number
Example
const n = api.schema.cardinality("role");
// 3