Implements property_many and has_many #46
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These two methods are helper methods intended to make graph traversal code much cleaner.
This is a simple step in making the code to insert vertices with many properties and querying these properties much cleaner.
Currently inserting vertices with many properties involves chaining a lot of
.property()
calls and can end up being many lines long.The same situation arises when de-serializing a
Map
into a rust data structure. Lots of chaining of.get()?.get()?
for each field in the struct.My thoughts to solve these two issues are the following:
.property()
chaining: we make public aToPropertyMany
Trait which a user can implement on their struct. This must return a Vec<(String, GValue)>. The user could then write code that might looks something like this:.get()
chaining: we have a derivable proc-macroTryFromGremlinMap
. This can be implemented on any struct containing types which can beInto<GValue>
. Then when a Map is returned from a given traversal the user can do the followingMyStruct::try_from_gremlin_map(map)?
. I have started the implementation for the proc macro at (https://github.com/jdeepee/gremlin-rs/tree/from_map_into_insertable/gremlin-derive) but its still very basic in its function. It also doesn't support serializing a GValue into another foreign type such as aUuid
.I am interested to know your thoughts on my proposal to solve these two issues. If you have any experience with proc macro's I could also use some help there. Still trying to understand them fully.