surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
294 stars 48 forks source link

Feature: RecordId class should error if passing a RecordId as parameter #242

Open vitorTheDev opened 5 months ago

vitorTheDev commented 5 months ago

Is your feature request related to a problem?

When upgranding from surreal.js 0.x.x to 1.x.x, it's common to cast string parameters as RecordId class. However, some of those values already come as a RecordId, causing mistakes in casting the recordId twice e.g.

new RecordId('table', new RecordId('table', 'id'))

This, instead of proper errors, causes weird behavior in surrealdb.

Describe the solution

The class creation should fail if the id or table parameters are instanceof RecordId with a proper error.

Alternative methods

OR maybe it should parse it correctly.

SurrealDB version

1.4.2 for windows on x86_64

SurrealDB.js version

1.0.0-beta.4

Contact Details

netd777@gmail.com

Is there an existing issue for this?

Code of Conduct