We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, in my own project, I wrote a method to work with Nebula row. It looks like this:
func LoadNebulaRow(colNames []string, row *nebulaType.Row, obj interface{}) interface{} { rowValues := row.GetValues() val := reflect.ValueOf(&obj).Elem() tmp := reflect.New(val.Elem().Type()).Elem() numField := reflect.ValueOf(obj).NumField() for i := 0; i < numField; i++ { fType := reflect.ValueOf(obj).Type().Field(i) tag := fType.Tag.Get("nebula") if tag == "" { continue } rowVal := rowValues[slices.Index(colNames, tag)] switch fType.Type.Kind() { case reflect.Int64: tmp.Field(i).SetInt(rowVal.GetIVal()) case reflect.String: tmp.Field(i).SetString(string(rowVal.GetSVal())) // ............ default: panic("not support type") } } val.Set(tmp) return obj }
The usage could be:
type AccountVertex struct { Src string `nebula:"src"` Dst string `nebula:"dst"` LinkType string `nebula:"link_type"` Status string `nebula:"account_status"` Tel string `nebula:"tel"` Email string `nebula:"email"` } // ... rs, err = NebulaClient.ExecQuery(q) if err != nil { // ... } cols = rs.GetColNames() rows = rs.GetRows() var data []AccountVertex for _, row := range rows { result := LoadNebulaRow(colNames, row, AccountVertex{}) data = append(data, result.(AccountVertex)) }
This is a draft from my use case, I am not sure it is suitable to load into this client package.
The text was updated successfully, but these errors were encountered:
Wow great job @haoxins !
@veezhang @Nicole00 what do you think, please?
Sorry, something went wrong.
I raised a draft PR for discussing the implementation details.
#298
Gooooood idea!
closed by #298
No branches or pull requests
Hi, in my own project, I wrote a method to work with Nebula row. It looks like this:
The usage could be:
This is a draft from my use case, I am not sure it is suitable to load into this client package.
The text was updated successfully, but these errors were encountered: