GithubHelp home page GithubHelp logo

Comments (5)

lukasbowen avatar lukasbowen commented on July 22, 2024

I am running into the same issue following the example.

type User struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
}


user:= User{
    Name: "Test",
}

data, err := handler.db.Create("user", user)
if err != nil {
    http.Error(w, err.Error(), http.StatusInternalServerError)
    return
}

// Unmarshal data
createdUser:= make([]User, 1)
err = surrealdb.Unmarshal(data, &createdUser)

from surrealdb.go.

lukasbowen avatar lukasbowen commented on July 22, 2024

Although from testing it the following will work. I am not sure if the document version using make([]User, 1) is attended or this updated example is the intended solution.

type User struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
}


user:= User{
    Name: "Test",
}

data, err := handler.db.Create("user", user)
if err != nil {
    http.Error(w, err.Error(), http.StatusInternalServerError)
    return
}

// Unmarshal data
createdUser:= User{}
err = surrealdb.Unmarshal(data, &createdUser)

from surrealdb.go.

ElecTwix avatar ElecTwix commented on July 22, 2024

Hi @lukasbowen and @thecodekitchen.
I'm sorry for your bad experience with the driver.
the problem you are facing is caused by RPC data response to change with beta 8 to 9.
The driver has been updated but there is no release at the moment.
You can use go get ithub.com/surrealdb/surrealdb.go@0316f40

If it is not working please let me know I can look into out.

also if docs are not enough you can look into
unit tests and tests the lib yourself.

from surrealdb.go.

ElecTwix avatar ElecTwix commented on July 22, 2024

@phughk I think we need to make a release.
for beta v9 fix.

from surrealdb.go.

phughk avatar phughk commented on July 22, 2024

Thanks ElecTwix! Will do that now

from surrealdb.go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.