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
I'm using rust writing a data model with a i64 numeric id field such as below:
struct Model {
id: i64,
...
}
After running SELECT queries, all data from the database has a record id, and I'm having trouble to deserialize them back to the model as it always reports:
called `Result::unwrap()` on an `Err` value: SurrealdbError("Failed to convert `{ avatar: '', email: '', id: User:45 }` to `T`: invalid type: map, expected i64")
As what I know, surrealdb stores record_id instead of just the numeric field. I know changing the id field to a Thing type may work or I can write another struct dedicated to this problem. But it will cause too much trouble for so many data types to convert types and code maintenance, and those models are also used for file generations which does not support the Thing type. So is there a way to just convert them back to the data model with corresponding field types?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using rust writing a data model with a
i64
numeric id field such as below:After running
SELECT
queries, all data from the database has a record id, and I'm having trouble to deserialize them back to the model as it always reports:As what I know, surrealdb stores record_id instead of just the numeric field. I know changing the id field to a
Thing
type may work or I can write another struct dedicated to this problem. But it will cause too much trouble for so many data types to convert types and code maintenance, and those models are also used for file generations which does not support theThing
type. So is there a way to just convert them back to the data model with corresponding field types?Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions