getRelationships

abstract fun getRelationships(className: String, entityAId: String? = null, entityBId: String? = null, classVersion: Int? = null, filterFast: String? = null, filter: String? = null, sort: List<PNDataSyncSortField> = emptyList(), limit: Int? = null, cursor: String? = null): GetRelationships

List DataSync relationships in a relationship class, optionally filtered by either end.

Unlike getMemberships, className is required — the relationship class to query is caller-supplied, not a fixed built-in one.

Filtering and sorting are only allowed on properties the relationship class marks as filterable via their filtering mode (none / simple / full), which also determines which of filterFast / filter / sort a property may be used with. The filterable set has no fixed default; it is whatever the supplied className declares as filterable payload properties (indexes over the relationship's /payload; the payload otherwise stays arbitrary JSON). In addition, the built-in fields id, createdAt, updatedAt, and status behave as full and are always filterable and sortable on any class, except that status may be excluded when the class declares it as a projected field and the token cannot fully reach it.

Results are scoped to the caller's access token: only relationships the token is permitted to read (get) are returned. Relationships the token cannot read are silently omitted — the call does not error and does not return a 403 for the un-readable relationships. Token scoping and the filterFast / filter / sort criteria are applied together, so the returned page never contains a relationship the token cannot read regardless of the other criteria. When the PubNub instance is configured with a secretKey (a trusted server-side deployment, never a client — the secretKey must not be shipped to clients), or when using a token whose grants cover the whole result set, no permission-based filtering is applied and all matching relationships are returned, subject only to filterFast / filter / sort and limit paging.

Parameters

className

Relationship class identifier to query.

entityAId

Optional entity A identifier to filter by. entityAId and entityBId are independent, AND-ed equality filters on the two sides of the relationship. Supplying only one narrows to relationships on that side; supplying both returns the relationships matching both; supplying neither lists all readable relationships in the class. This is not a pair-only lookup API.

entityBId

Optional entity B identifier to filter by. See entityAId for how the two combine.

classVersion

Restricts results to a single version of the relationship class. If null, items of every version are returned, while filterFast, filter and sort fields are checked against the latest version. Pass a version to make results stable when new class versions are published.

filterFast

Optional filter expression. filterFast is strongly consistent — it always reflects the latest writes — but accepts fewer conditions than filter; a limit on the number of conditions applies and can be adjusted by PubNub support (see the PubNub DataSync documentation for the current limit). For larger or more complex queries use filter. At most one of filterFast and filter may be supplied; sending both is rejected by the server (HTTP 400).

filter

Optional advanced filter expression. Uses the same syntax as filterFast. It is not subject to the same condition limit, so use it for larger or more complex queries. The trade-off is consistency: filter is eventually consistent (recent writes may not yet be reflected), whereas filterFast is strongly consistent. At most one of filterFast and filter may be supplied; sending both is rejected by the server (HTTP 400).

sort

Optional sort criteria applied in order; each PNDataSyncSortField sorts on a property either ascending (default) or descending.

limit

Optional page size, 1–100 (server default 20). A value outside that range is rejected by the server (HTTP 400), not clamped.

cursor

Optional opaque cursor for pagination (from a previous result's next.cursor).