Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.SetProperty Only Allows String Properties #73

Open
brad-ross opened this issue Apr 1, 2015 · 5 comments
Open

Node.SetProperty Only Allows String Properties #73

brad-ross opened this issue Apr 1, 2015 · 5 comments

Comments

@brad-ross
Copy link

The function signature of Node.SetProperty is as follows:

func (e *Node) SetProperty(key string, value string) error

I would like my value to be a bool. Can you make the type of value be interface{}? You should be able to deal with non-string properties as you do when you pass a neoism.Props struct to Node.SetProperties...

@vsiv
Copy link

vsiv commented Apr 10, 2015

+1
I made the same comment earlier, as I have bool and array props

@vsiv
Copy link

vsiv commented Apr 10, 2015

@jmcvetta unfortunately changing the sig from string to interface{} will not be backward compatible. I can send a pull request, but to be backward compatible, i will have to add a new method - if u like that - whats a good name for the method for code convention...

@vsiv
Copy link

vsiv commented Apr 10, 2015

@brad-ross-35 in the meantime i just implemented the method myself - if u need here u go.. please note to test in ur env and production...

func SetNodeIfcProperty(n *neoism.Node, key string, value interface{}) error {
    parts := []string{n.HrefProperties, key}
    url := strings.Join(parts, "/")
        ne := neoism.NeoError{}
    resp, err := napping.Put(url, &value, nil, &ne)
    if resp == nil {
        // empty response
    } else if err != nil {
        return err
    } else if resp.Status() != 204 {
        return ne
    }
    return nil  // success
}

@brad-ross
Copy link
Author

Thanks! I found a way around the problem, but hopefully there will be a patch soon--backwards compatibility shouldn't be a big issue, and I'm sure people using the library would rather account for the change than go on without being able to use non-string properties.

@jmcvetta
Copy link
Owner

Please feel free to submit a Pull Request with your suggested changes. Contributions are happily accepted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants