Skip to content

API Reference

/

Utilities

dedupeTrace

Available since: v4.0.0

dedupeTrace()

The dedupeTrace() function removes the entries of a query trace that repeat an earlier entry, and keeps the first copy of each. A statement can report the same edge, reference or link on more than one frame, and .responses() and .statements() join the frames as they were sent.

Import:

import { dedupeTrace } from 'surrealdb';

Source: utils/dedupe-trace.ts

function dedupeTrace(trace: QueryTrace): QueryTrace

Parameter

Type

Description

traceQueryTrace

The trace to remove repeated entries from. It is not changed.

QueryTrace - A trace that holds each entry once

Entries are identified by their record ids, and a link also by its field. Subscriptions are identified by their id. Variables are keyed by name, so they cannot repeat.

const [response] = await db
    .query('SELECT ->tagged->tag FROM post')
    .trace('relations')
    .responses();

if (response.success && response.trace) {
    const unique = dedupeTrace(response.trace);
}

Was this page helpful?