Open jinrenjie opened 1 month ago
Go struct:
type Project struct { marshal.Basemodel `table:"projects"` ID string `json:"id,omitempty"` Name string `json:"name"` Icon string `json:"icon,omitempty"` Desc string `json:"desc"` Owner string `json:"owner"` Status int32 `json:"status"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` DeletedAt *time.Time `json:"deleted_at,omitempty"` }
Record in SurrealDB:
{ "desc": "description", "icon": "icon-focusly", "id": "projects:⟨a81e88fa-05a2-4e0a-90c6-5f3bceaea7d6⟩", "name": "focusly", "owner": "NONE", "status": 1 }
Error Log:
json: cannot unmarshal object into Go struct field Project.id of type string
Query project records:
queryRes, err := db.Query("SELECT * FROM projects", nil) if err != nil { journal.Logger.Error(err) return nil, err } // Other convert logic in here...... err = marshal.Unmarshal(queryResMap["result"], &ProjectItems) if err != nil { journal.Logger.Error(err) return nil, err }
Unmarshal json models.RecordID to string ID in Go struct.
surreal 2.0.1 for macOS on aarch64
george@betterde.com
Describe the bug
Go struct:
Record in SurrealDB:
Error Log:
Steps to reproduce
Query project records:
Expected behaviour
Unmarshal json models.RecordID to string ID in Go struct.
SurrealDB version
surreal 2.0.1 for macOS on aarch64
Contact Details
george@betterde.com
Is there an existing issue for this?
Code of Conduct