Closed dodanex closed 2 months ago
Hey @dodanex! I haven't had the time just yet to update the docs unfortunately, but the way Record IDs and some other native types are represented is changing in surrealdb.js v1.0.0. Due to the newly introduced CBOR protocol, we now have an understanding of values native to SurrealQL, but not JSON, like Record IDs.
This means that you would now use the new RecordId
class to select, create or alter specific records, like so:
await db.select(new RecordId("table", "id"));
As some people mentioned they had some usecases where they need to be able to work with string representations of Record IDs, I did the work in #256 to make this possible again, like
const res = await db.select(new StringRecordId("table:id"));
res.id.toString();
Lastly, selecting, creating or altering a specific Record ID instead of a table in general will now return just the object representing that record, instead of an array of objects.
This will be pushed in the next beta, I hope this helps!
Thank you for your detailed answer!
Describe the bug
The select function is not working when adding an ID, for example:
db.select('table:id')
will not return the correct result, but an empty array. Same happens for the update() and delete() functions.The JSON result from the
select()
orcreate()
function is not consistent with what the database shows in the Surrealist or when directly calling the database via CURL http://localhost:8000/sql and selecting.Here you have a screenshot with the Surrealist result and the Network request from Browser Developer Tools made in an Nuxt app:![Screenshot 2024-04-27 034003](https://github.com/surrealdb/surrealdb.js/assets/16241982/24ed219d-24e6-42a9-a55c-0e1ef88a8745)
In the old version v0.11.1 those methods worked fine!
Steps to reproduce
Connect to the database using
surrealdb.js v1.0.0-beta.5
and try to get a result by id usingdb.select('table:id')
and you will get an empty array. Also test fordb.delete('table:id')
anddb.select('table:id', object)
Then do the same request using
v0.11.1
and you will get the correct result.Expected behaviour
SurrealDB version
1.4.2
SurrealDB.js version
1.0.0-beta.5
Contact Details
No response
Is there an existing issue for this?
Code of Conduct