Skip to content

Conversation

@msanchezdev
Copy link

Thank you for submitting this pull request! We appreciate you spending the time to work on these changes.

What is the motivation?

Currently you cannot see what's the table or id of a Record IDs without accessing table and id properties explicitly.

What does this change do?

Adds custom inspect to RecordId, StringRecordId and RecordIdRange so they are properly printed while console.log'ging. This also helps testing frameworks to properly compare record ids as comparing two RecordId instances seems to wrongly compare the two as being equal even if they have different table or id.

Screenshot 2025-11-17 161044

What is your testing strategy?

A quick way to test this is with the following snippet, created at packages/sdk/sandbox.ts:

import { RecordId, Surreal, Table } from "./src";

const surreal = new Surreal();
await surreal.connect("ws://127.0.0.1:8000", {
    namespace: "test",
    database: "test",
    authentication: {
        username: "root",
        password: "Welc0me123.",
    },
});

// Insert 10 fake users
await surreal.upsert(new RecordId("user", 1)).content({
    name: `User 1`,
    email: `[email protected]`,
    age: 20,
    active: true,
});
await surreal.upsert(new RecordId("user", "2")).content({
    name: `User 1`,
    email: `[email protected]`,
    age: 20,
    active: true,
});
await surreal.upsert(new RecordId("user", [3])).content({
    name: `User 1`,
    email: `[email protected]`,
    age: 20,
    active: true,
});
await surreal.upsert(new RecordId("user", { domain: "example.com", username: `user3` })).content({
    name: `User 1`,
    email: `[email protected]`,
    age: 20,
    active: true,
});

const users = surreal.select(new Table("user")).stream();
for await (const user of users) {
    if (user.isValue()) {
        console.log(user.value);
    }
}

await surreal.close();

Is this related to any issues?

No

Have you read the Contributing Guidelines?

@msanchezdev msanchezdev requested a review from kearfy as a code owner November 17, 2025 17:02
@msanchezdev msanchezdev force-pushed the custom-record-id-inspect branch from e02c6be to ce3add4 Compare November 17, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant