schema

schema.cardinality

cardinality(key: string, scope: "nodes" | "edges"): number

Total distinct values for a property key (full scan).

Unlike values() this always scans the entire graph to give an exact count.

keystringThe property key to count distinct values for.
scope"nodes" | "edges""nodes" (default) or "edges".

Returns: number

Example

const n = api.schema.cardinality("role");
// 3