UNWIND with the official Go driver

Does anyone have an example of an UNWIND statement they've done to run multiple CREATE statements?

I am able to do it, but I have to pass in an array of map[string][string] which is a bit ugly. I don't know if there's a way to pass in a Struct or anything?

I am also trying to do it with go but no success.. Any help?

The go driver only accepts a map[string]interface{} as parameters and do not support passing struct types. My suggestion would be parallel to what you're already doing, like mapping your own array of struct values to into array of map[string]interface{} and providing that result as a parameter.

I have added a simple gist to showcase a simple way to go forward.


Thanks a lot, you saved the day for gophers!

@ali_ince I have been working with your example and it seems that the Go driver unwinds based on the index key of the map. 0, 1, 2, 3, etc. The results also seem to be returned in the same order as the index key on the map. Can you confirm this is the expected behaviour please or is this just a coincidence?

For our use case, we require the order in, to be the same as the order out, so that we can update the original slice of structs with the Node IDs.

We are migrating from Node.js, where unwinding an array, the order in was the same as the order out.