Open cstetson opened 6 years ago
Hi @cstetson. You should be using RunWrite
instead of Run
for write operations (see this). This will return a WriteResponse
struct where you can simply access its Changes
property. So it may look something like this:
resp, _ = db.DB("content").Table("posts").Get(articleId).Delete(r.DeleteOpts{ReturnChanges: true}).RunWrite(session)
fmt.Printf("%+v\n", resp)
fmt.Println(reflect.TypeOf(resp.Changes)) // []gorethink.ChangeResponse
@pohzipohzi suggested the right way to get changes, but why json unmarshals to a single struct is needed to be researched.
I am working with a microservice application where I need to get back the values for a record that I delete and using the "ReturnChanges" feature of rethink is perfect for this. It works for update and replace, but fails for delete.
The return values for the changes come as
Where it should be returning the changes as an array:
Rethink returns the proper json structure.