You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cbor: cannot unmarshal array into Go struct field
connection.RPCResponse[github.com/surrealdb/surrealdb%2ego.QueryResult[ReturnUser]].result of type
surrealdb.QueryResult[ReturnUser·1] (cannot decode CBOR array to struct without toarray option)
Your ID field in the struct needs to be type models.RecordID. That is how the CBOR Unmarshal knows it is a record ID. Later on your then get the value of the table or ID by doing recordID.ID or something along those lines.
Also if your query is expected to return multiple records, the query needs to provide the type as a slice (i.e. Query[[]user](...).
@remade no need to work on this, I worked on this for 2 days, there is no way to make this happen, the closest way is to define a new type type RecordIDBasic string, which still needs to be casted to string type. I decided I'll just use RecordId struct. and make changes to my code.
The only way to make this happen is on cbor side, which I left a discussion fxamacker/cbor#599
Describe the bug
for Query function, got error
Steps to reproduce
response cbor data structure:
Expected behaviour
no error
SurrealDB version
surreal 2.0.4
Contact Details
No response
Is there an existing issue for this?
Code of Conduct
The text was updated successfully, but these errors were encountered: