Skip to content

Support for structs in properties #101

@notdodo

Description

@notdodo

Feature Request:

Add support for this kind of properties definition:

type Sub struct {
	A int
	B string
	C []SubSub
}

type SubSub struct {
	D int
}

type VertexA struct {
	gogm.BaseNode
	// provides required node fields

	TestField     string            `gogm:"name=test_field"`
	TestStruct         Sub               `gogm:"name=test_struct;properties"`
	MapProperty   map[string]string `gogm:"name=map_property;properties"`
	SliceProperty []string          `gogm:"name=slice_property;properties"`
	SingleA       *VertexB          `gogm:"direction=incoming;relationship=test_rel"`
	ManyA         []*VertexB        `gogm:"direction=incoming;relationship=testm2o"`
	MultiA        []*VertexB        `gogm:"direction=incoming;relationship=multib"`
	SingleSpecA   *EdgeC            `gogm:"direction=outgoing;relationship=special_single"`
	MultiSpecA    []*EdgeC          `gogm:"direction=outgoing;relationship=special_multi"`
}

It should be useful to store custom defined structs inside the node properties; as a side note a possible way to achieve this could be to flatten the struct into something like TestStruct_A, TestStruct_B, TestStruct_C_D_0.

Context

This feature could be used to directly upload complex struct into the node (i.e. coming from a JSON response/data).

Alternatives

I don't it is possible without manually rewriting the node structure with the required fields since the library only support primitive types.

Would you be interested in implementing this feature?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions