You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would love to see the references feature beefed up a little. A couple wish list items:
A SaveReference option for InsertOpts and UpdateOpts
this would tell the driver to save any nested reference items as well. in the gist example this call (it's corresponding output) would reflect the changes to it's referenced Author.Name (from here) field as well.
Value: If I'm working with a complex, nested structure with updates to several different nested fields, I can make one gorethink call to save all changes.
Introduce an equivalent GetOpts that includes a GetReference option to automatically find reference fields and intelligently does the Merge operation when it runs the query.
Value: user no longer has to worry about constructing merge functions or ensuring that they stay up to date
I'm not entirely sure on the feasibility of these features, but i postulate (without any deep knowledge on how the driver constructs and performs the rethinkdb queries) an approach could be to introduce a new struct tag, gorethink_ref_table which would be the string value of the table name currently included in the merge function's parameter, and use that tag value to construct the relevant sub-queries to execute.
And API calls to get a book / save book & author changes from the referenced book could be simplified to:
/*** get ***/r.Table("book").Get("aBookRowID", r.GetOpts{GetReference: true}).Run(rethink)
/*** save ***/r.Table("book").Insert(aBookItemWithChanges).RunWrite(rethink)
r.Table("author").Insert(aBookItemWithChanges.Author).RunWrite(rethink)
// could be simplified to r.Table("book").Insert(aBookItemWithChanges, r.InsertOpts{SaveReference: true}).RunWrite(rethink)
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion @spxrogers, unfortunately I do not have the time to work on this feature right now but if you (or anybody else) could submit a PR I would definitely consider merging it into the driver.
[see gist]
Would love to see the references feature beefed up a little. A couple wish list items:
SaveReference
option forInsertOpts
andUpdateOpts
Author.Name
(from here) field as well.GetOpts
that includes aGetReference
option to automatically find reference fields and intelligently does theMerge
operation when it runs the query.I'm not entirely sure on the feasibility of these features, but i postulate (without any deep knowledge on how the driver constructs and performs the rethinkdb queries) an approach could be to introduce a new struct tag,
gorethink_ref_table
which would be the string value of the table name currently included in the merge function's parameter, and use that tag value to construct the relevant sub-queries to execute.Then the structs could be updated to:
And API calls to get a book / save book & author changes from the referenced book could be simplified to:
The text was updated successfully, but these errors were encountered: